-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from keminar/todo
增加指定代理功能
- Loading branch information
Showing
8 changed files
with
124 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#!/bin/bash | ||
SCRIPT=$(readlink -f $0) | ||
ROOT_DIR=$(dirname $SCRIPT)/../ | ||
cd $ROOT_DIR | ||
|
||
# for alpine | ||
go build -tags netgo -o anyproxy.netgo anyproxy.go | ||
|
||
# common | ||
go build -o anyproxy anyproxy.go | ||
go build -o tunnel/tunneld tunnel/tunneld.go | ||
go build -o tunnel/tunneld tunnel/tunneld.go |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
sudo useradd -M -s /sbin/nologin anyproxy | ||
sudo iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner anyproxy -j RETURN | ||
sudo iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-port 3000 | ||
#!/bin/bash | ||
SCRIPT=$(readlink -f $0) | ||
ROOT_DIR=$(dirname $SCRIPT)/../ | ||
cd $ROOT_DIR | ||
ulimit -n 65536 | ||
|
||
if ! (sudo cat /etc/passwd|grep ^anyproxy: > /dev/null); then | ||
echo "添加账号" | ||
sudo useradd -M -s /sbin/nologin anyproxy | ||
fi | ||
|
||
# 要启动的端口 | ||
port=3000 | ||
if ! (sudo iptables -t nat -L|grep "redir ports $port" > /dev/null); then | ||
echo "添加iptables" | ||
# anyproxy 账号不走代理直接请求 | ||
sudo iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner anyproxy -j RETURN | ||
|
||
# 注:如果有虚拟机,虚拟机的启动账号不要走代理端口,会导致虚拟机里的浏览器设置的代理无效果 | ||
# 如果有本地账号要连mysql等服务,也不要走代理端口,会一直卡住(目前发现mysql协议不兼容) | ||
|
||
#指定root账号走代理 | ||
sudo iptables -t nat -A OUTPUT -p tcp -j REDIRECT -m owner --uid-owner 0 --to-port $port | ||
#其它账号可以走代理 | ||
#sudo iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-port $port | ||
fi | ||
echo "启动anyproxy" | ||
sudo -u anyproxy ./anyproxy -daemon -l $port |
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