starts filling the buffer before a tor instance is live
This commit is contained in:
parent
a8841a2f40
commit
1cc2a57394
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tor-router",
|
"name": "tor-router",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"repository": "git@github.com:znetstar/tor-router.git",
|
"repository": "git@github.com:znetstar/tor-router.git",
|
||||||
"author": "Zachary Boyd <zachary@zacharyboyd.nyc>",
|
"author": "Zachary Boyd <zachary@zacharyboyd.nyc>",
|
||||||
|
|
|
@ -8,8 +8,8 @@ class DNSServer extends UDPServer {
|
||||||
this.tor_pool = tor_pool;
|
this.tor_pool = tor_pool;
|
||||||
|
|
||||||
this.on('request', (req, res) => {
|
this.on('request', (req, res) => {
|
||||||
for (let question of req.question) {
|
|
||||||
let connect = (tor_instance) => {
|
let connect = (tor_instance) => {
|
||||||
|
for (let question of req.question) {
|
||||||
let dns_port = (tor_instance.dns_port);
|
let dns_port = (tor_instance.dns_port);
|
||||||
let outbound_req = dns.Request({
|
let outbound_req = dns.Request({
|
||||||
question,
|
question,
|
||||||
|
@ -37,7 +37,7 @@ class DNSServer extends UDPServer {
|
||||||
|
|
||||||
outbound_req.send();
|
outbound_req.send();
|
||||||
};
|
};
|
||||||
|
};
|
||||||
if (this.tor_pool.instances.length) {
|
if (this.tor_pool.instances.length) {
|
||||||
connect(this.tor_pool.next());
|
connect(this.tor_pool.next());
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ class DNSServer extends UDPServer {
|
||||||
this.log.debug(`[dns]: a connection has been attempted, but no tor instances are live... waiting for an instance to come online`);
|
this.log.debug(`[dns]: a connection has been attempted, but no tor instances are live... waiting for an instance to come online`);
|
||||||
this.tor_pool.once('instance_created', connect);
|
this.tor_pool.once('instance_created', connect);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,9 +12,7 @@ class SOCKSServer extends SOCKS5Server{
|
||||||
var outbound_socket;
|
var outbound_socket;
|
||||||
let buffer = [];
|
let buffer = [];
|
||||||
|
|
||||||
let connect = (tor_instance) => {
|
let onInboundData = (data) => buffer.push(data)
|
||||||
let socks_port = tor_instance.socks_port;
|
|
||||||
logger && logger.info(`[socks]: ${info.srcAddr}:${info.srcPort} → 127.0.0.1:${socks_port} → ${info.dstAddr}:${info.dstPort}`)
|
|
||||||
|
|
||||||
let onClose = (error) => {
|
let onClose = (error) => {
|
||||||
inbound_socket && inbound_socket.end();
|
inbound_socket && inbound_socket.end();
|
||||||
|
@ -28,16 +26,18 @@ class SOCKSServer extends SOCKS5Server{
|
||||||
d.exit();
|
d.exit();
|
||||||
};
|
};
|
||||||
|
|
||||||
d.on('error', onClose);
|
|
||||||
|
|
||||||
let onInboundData = (data) => buffer.push(data)
|
|
||||||
|
|
||||||
if (!inbound_socket) return;
|
if (!inbound_socket) return;
|
||||||
|
|
||||||
inbound_socket.on('close', onClose);
|
inbound_socket.on('close', onClose);
|
||||||
inbound_socket.on('data', onInboundData);
|
inbound_socket.on('data', onInboundData);
|
||||||
inbound_socket.on('error', onClose);
|
inbound_socket.on('error', onClose);
|
||||||
|
|
||||||
|
let connect = (tor_instance) => {
|
||||||
|
let socks_port = tor_instance.socks_port;
|
||||||
|
logger && logger.info(`[socks]: ${info.srcAddr}:${info.srcPort} → 127.0.0.1:${socks_port} → ${info.dstAddr}:${info.dstPort}`)
|
||||||
|
|
||||||
|
d.on('error', onClose);
|
||||||
|
|
||||||
d.run(() => {
|
d.run(() => {
|
||||||
socks.connect({
|
socks.connect({
|
||||||
host: info.dstAddr,
|
host: info.dstAddr,
|
||||||
|
|
Loading…
Reference in a new issue