59 lines
1.1 KiB
Bash
Executable File
59 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
source ./00_env.sh
|
|
set -euo pipefail
|
|
|
|
apt install -y build-essential libevent-dev libssl-dev git || true
|
|
|
|
if ! command -v redsocks >/dev/null 2>&1; then
|
|
cd /tmp
|
|
git clone https://github.com/semigodking/redsocks.git
|
|
cd redsocks
|
|
make
|
|
cp redsocks /usr/sbin/redsocks
|
|
fi
|
|
|
|
cat >/etc/redsocks.conf <<EOL
|
|
base {
|
|
log_debug = off;
|
|
log_info = on;
|
|
daemon = on;
|
|
redirector = iptables;
|
|
}
|
|
|
|
redsocks {
|
|
local_ip = 127.0.0.1;
|
|
local_port = $REDSOCKS_PORT;
|
|
ip = $SOCKS5_SERVER;
|
|
port = $SOCKS5_PORT;
|
|
type = socks5;
|
|
autoproxy = 0;
|
|
}
|
|
|
|
redsocks {
|
|
local_ip = 127.0.0.1;
|
|
local_port = $REDSOCKS_DNS_PORT;
|
|
ip = $SOCKS5_SERVER;
|
|
port = $SOCKS5_PORT;
|
|
type = socks5;
|
|
autoproxy = 0;
|
|
}
|
|
EOL
|
|
|
|
cat >/etc/systemd/system/redsocks.service <<EOL
|
|
[Unit]
|
|
Description=Redsocks2 transparent proxy
|
|
After=network-online.target ipset-load.service
|
|
Wants=network-online.target
|
|
[Service]
|
|
ExecStart=/usr/sbin/redsocks -c /etc/redsocks.conf
|
|
Restart=on-failure
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOL
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable redsocks
|
|
systemctl restart redsocks || true
|
|
|
|
echo "redsocks2 配置完成"
|