-
Notifications
You must be signed in to change notification settings - Fork 388
/
wireproxy.sh
49 lines (35 loc) · 1.53 KB
/
wireproxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
PORT="${1:-1080}"
USER="${2:-}"
PASSWORD="${3:-}"
WORK=`mktemp -d`
trap "rm -rf ${WORK}" EXIT
case `uname -m` in aarch64|arm64) arch="arm64";; x86_64|amd64) arch="amd64";; *) arch="";; esac
[ -n "$arch" ] || exit 1
[ -f ./wireproxy ] && cp ./wireproxy "${WORK}" || curl -sSL "https://api.github.com/repos/pufferffish/wireproxy/releases/latest" |grep "browser_download_url" |grep "linux" |grep "${arch}" |cut -d'"' -f4 |xargs curl -sSL |tar -zx -C "${WORK}"
[ $? -eq 0 ] || exit 1
[ -f ./wgcf ] && cp ./wgcf "${WORK}" || curl -sSL "https://api.github.com/repos/ViRb3/wgcf/releases/latest" |grep "browser_download_url" |grep "linux" |grep "${arch}" |cut -d'"' -f4 |xargs curl -sSL -o "${WORK}/wgcf"
[ $? -eq 0 ] || exit 1
chmod -R 777 "${WORK}"
cd "${WORK}"
./wgcf register --config ./wgcf-account.toml --accept-tos >/dev/null 2>&1
./wgcf generate --config ./wgcf-account.toml -p ./wgcf-profile.conf >/dev/null 2>&1
cat >"./wireproxy.conf"<< EOF
[Interface]
`cat ./wgcf-profile.conf |grep '^PrivateKey'`
`cat ./wgcf-profile.conf |grep '^Address'`
DNS = 8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844
`cat ./wgcf-profile.conf |grep '^MTU'`
[Peer]
`cat ./wgcf-profile.conf |grep '^PublicKey'`
AllowedIPs = ::/0
Endpoint = [2606:4700:d0::a29f:c001]:2408
[Peer]
`cat ./wgcf-profile.conf |grep '^PublicKey'`
AllowedIPs = 0.0.0.0/0
Endpoint = 162.159.192.1:2408
[Socks5]
BindAddress = 0.0.0.0:${PORT}
`[ -n "${USER}" ] && [ -n "${PASSWORD}" ] && echo -en "Username = ${USER}\nPassword = ${PASSWORD}"`
EOF
./wireproxy -c ./wireproxy.conf