This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf | |
INTERFACE=eth0 | |
PROTOCOL=tcp | |
LOCAL_PORT=8080 | |
REMOTE_HOST=www.baidu.com | |
REMOTE_PORT=80 | |
echo "forward $PROTOCOL `ip -4 -o addr show $INTERFACE | awk '{print $4}' | cut -d "/" -f 1`:$LOCAL_PORT to $REMOTE_HOST:$REMOTE_PORT" | |
iptables -t nat -A PREROUTING -p $PROTOCOL -i $INTERFACE --dport $LOCAL_PORT -j DNAT --to $REMOTE_HOST:$REMOTE_PORT | |
iptables -t nat -A POSTROUTING -j MASQUERADE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const PROXY_PASS = 'http://www.google.com'; | |
const HTTP_PROXY_PORT = 8888; | |
const HTTP_PROXY_HOST = '127.0.0.1'; | |
const getOptions = (request) => ({ | |
hostname: HTTP_PROXY_HOST, | |
port: HTTP_PROXY_PORT, | |
path: PROXY_PASS + request.url, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Iterator (next) { | |
this[Symbol.iterator] = function () { | |
let obj = { next }; | |
obj[Symbol.iterator] = function () { | |
return this; | |
} | |
return obj; | |
}; | |
}; |