Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function connect (req, cltSocket, head, hostname, port) {
// tunneling https
var proxySocket = net.connect(port, hostname, () => {
cltSocket.write('HTTP/1.1 200 Connection Established\r\n' +
'Proxy-agent: node-mitmproxy\r\n' +
'\r\n');
proxySocket.write(head);
proxySocket.pipe(cltSocket);
cltSocket.pipe(proxySocket);
});
proxySocket.on('error', (e) => {
console.log(colors.red(e));
});
return proxySocket;
}
resolveHost(url || tunnelUrl, function(ip) {
resSocket = net.connect(options.port, ip, function() {
resSocket.pipe(reqSocket).pipe(resSocket);
sendEstablished();
});
abortIfUnavailable(resSocket);
}, ip);
}
constructor(props) {
this.conn = net.connect(props.port || 3490, props.host || 'localhost');
this.noEcho = props.noEcho;
this.conn.setNoDelay(true);
this.conn.once('ready', this.connect.bind(this));
}
function connect () {
socket = net.connect({ port: PORT }, onConnect)
socket.on('error', retry)
socket.on('end', onEnd)
}