diff --git a/lib/Client.js b/lib/Client.js index 176c038..123d2a7 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -74,13 +74,13 @@ Client.prototype.connect = function() { return; this.emit("status", "Connecting..."); if(typeof module !== "undefined") { + let headers = { + "origin": `https://${new URL(this.uri).host}`, + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" + }; + if (this.uri.includes("multiplayerpiano.com")) headers["X-Forwarded-For"] = `${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}`; // nodejsicle - this.ws = new WebSocket(this.uri, { - headers: { - "origin": `https://${new URL(this.uri).host}`, - "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" - } - }); + this.ws = new WebSocket(this.uri, {headers}); } else { // browseroni this.ws = new WebSocket(this.uri);