mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 10:42:53 +00:00
Made changes to ubuntu-server to reject connections not from localhost
Signed-off-by: Volodymyr Kozieiev <vkjr.sp@gmail.com>
This commit is contained in:
parent
b0449f3416
commit
807e816936
@ -114,6 +114,18 @@ function rnUbuntuServer(readable, writable) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var closeDangerousConnection = function(sock) {
|
||||||
|
var remoteAddress = sock.remoteAddress;
|
||||||
|
if(remoteAddress.indexOf("127.0.0.1") == -1) {
|
||||||
|
console.log("WARN: connection not from localhost, will be closed: ", remoteAddress);
|
||||||
|
sock.destroy();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
console.log("Connection from: ", remoteAddress);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (process.argv.indexOf('--pipe') != -1) {
|
if (process.argv.indexOf('--pipe') != -1) {
|
||||||
console.log = console.error
|
console.log = console.error
|
||||||
rnUbuntuServer(process.stdin, process.stdout);
|
rnUbuntuServer(process.stdin, process.stdout);
|
||||||
@ -127,6 +139,7 @@ if (process.argv.indexOf('--pipe') != -1) {
|
|||||||
|
|
||||||
var server = net.createServer((sock) => {
|
var server = net.createServer((sock) => {
|
||||||
DEBUG && console.error("-- Connection from RN client");
|
DEBUG && console.error("-- Connection from RN client");
|
||||||
|
if(!closeDangerousConnection(sock))
|
||||||
rnUbuntuServer(sock, sock);
|
rnUbuntuServer(sock, sock);
|
||||||
}).listen(port, function() { console.error("-- Server starting") });
|
}).listen(port, function() { console.error("-- Server starting") });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user