goproxy 官网 https://goproxy.cn/
go语言开发的简单易用高性能proxy 软件
#!/bin/bash
# time: 2021-05-11 17:47:39
# by: Chen
##执行脚本需要传入网络设备名
##例:sh goproxy-install.sh eth0# 0.安装必须要的依赖
yum install wget -y || apt install wget -yfunction install_proxy {
# 1.安装 proxy
# 说明: https://github.com/snail007/goproxy/blob/master/README_ZH.md
# 引用: https://mirrors.host900.com/https://github.com/snail007/goproxy/blob/master/install_auto.shF="proxy-linux-amd64.tar.gz"
set -e
if [ -e /tmp/proxy ]; thenrm -rf /tmp/proxy
fi
mkdir /tmp/proxy
cd /tmp/proxyecho -e "\n>>> downloading ... $F\n"
manual="https://snail.gitee.io/proxy/manual/"
LAST_VERSION=$(curl --silent "https://mirrors.host900.com/https://api.github.com/repos/snail007/goproxy/releases/latest" | grep -Po '"tag_name":"\K.*?(?=")')
wget -t 1 "https://mirrors.host900.com/https://github.com/snail007/goproxy/releases/download/${LAST_VERSION}/$F"echo -e ">>> installing ... \n"
# #install proxy
tar zxvf $F >/dev/null
set +e
killall -9 proxy >/dev/null 2>&1
set -e
cp -f proxy /usr/bin/
chmod +x /usr/bin/proxy
if [ ! -e /etc/proxy ]; thenmkdir /etc/proxycp blocked /etc/proxycp direct /etc/proxy
fi
if [ ! -e /etc/proxy/proxy.crt ]; thencd /etc/proxy/proxy keygen -C proxy >/dev/null 2>&1
fi
rm -rf /tmp/proxy
version=`proxy --version 2>&1`
echo -e ">>> install done, thanks for using snail007/goproxy $version\n"
echo -e ">>> install path /usr/bin/proxy\n"
echo -e ">>> configuration path /etc/proxy\n"
echo -e ">>> uninstall just exec : rm /usr/bin/proxy && rm -rf /etc/proxy\n"
echo -e ">>> How to using? Please visit : $manual\n"}function add_service {
# 2.添加为服务
cat > /etc/systemd/system/jasper-proxy-${net_name}.service <<EOF
[Unit]
Description=Provide Socket Proxy For 'JasPer'
Wants=network.target
After=network.target[Service]
User=root
PermissionsStartOnly=trueEnvironment='EXT_IP=`curl --interface ${net_name} -s ifconfig.co`'
Environment="LISTEN_ON=`ip a s ${net_name} | grep -oP '(?<=inet\s)\d+(\.\d+){3}'`:3128"# socket5 mode
# ExecStart=/usr/bin/proxy socks -g \$EXT_IP -t tcp -p \$LISTEN_ON# http mode
ExecStart=/usr/bin/proxy http -g \$EXT_IP -p \$LISTEN_ONRestart=always
RestartSec=15s
TimeoutStartSec=30s[Install]
WantedBy=multi-user.target
EOF# 3.开机启动
systemctl daemon-reload
systemctl enable jasper-proxy-${net_name}.service
systemctl start jasper-proxy-${net_name}.service
systemctl status jasper-proxy-${net_name}.service
}net_name=$1
if [ ! -n "$net_name" ];thenecho -e "缺少\$1参数,无网络设备名称 "sleep 1exit
fiproxy --version
if [ $? != 0 ];theninstall_proxyadd_service
else add_service
fi