var net = require('net');
net.createServer(function(from) {
var ip = from.remoteAddress.substring(7);
if(ttutil.getIpWhiteList().indexOf(ip) == -1)
return;
var to = net.createConnection({
host: host,
port: port
});
from.pipe(to);
to.pipe(from);
from.on("error", function (error){
to.end();
});
to.on("error", function (error){
from.end();
});
}).listen(port);
另附nginx
stream {
upstream backend_7999 {
hash $remote_addr consistent;
server 120.77.179.153:7999;
}
server {
listen 7999;
proxy_connect_timeout 30s;
proxy_timeout 30s;
proxy_pass backend_7999;
}
}
网友评论