Skip to content

Commit a309328

Browse files
committed
fix: only allow connections to a specific server by default
1 parent bfe48e8 commit a309328

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

wsproxy.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,18 @@ let srv = {
368368
let host = s.host || srv.tn_host;
369369
let port = s.port || srv.tn_port;
370370

371+
if (!s.ttype) s.ttype = [];
372+
373+
s.ttype = s.ttype.concat(srv.ttype.portal.slice(0));
374+
s.ttype.push(s.remoteAddress);
375+
s.ttype.push(s.remoteAddress);
376+
377+
s.compressed = 0;
378+
371379
// do not allow the proxy connect to different servers
372380
if (ONLY_ALLOW_DEFAULT_SERVER) {
373381
if (s.host !== srv.tn_host) {
382+
srv.log('avoid connection attempt to: ' + s.host + ':' + s.port, s);
374383
srv.sendClient(
375384
s,
376385
new Buffer(
@@ -379,19 +388,10 @@ let srv = {
379388
'Take a look to https://github.com/maldorne/mud-web-proxy/ and install it in your own server.\r\n'
380389
)
381390
);
382-
srv.log('attempt connection to: ' + s.host + ':' + s.port, s);
383391
srv.closeSocket(s);
384392
}
385393
}
386394

387-
if (!s.ttype) s.ttype = [];
388-
389-
s.ttype = s.ttype.concat(srv.ttype.portal.slice(0));
390-
s.ttype.push(s.remoteAddress);
391-
s.ttype.push(s.remoteAddress);
392-
393-
s.compressed = 0;
394-
395395
s.ts = net.createConnection(port, host, function () {
396396
srv.log(
397397
'new connection to ' + host + ':' + port + ' for ' + s.remoteAddress

0 commit comments

Comments
 (0)