1
0

wireproxy.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. PORT="${1:-1080}"
  3. USER="${2:-}"
  4. PASSWORD="${3:-}"
  5. WORK=`mktemp -d`
  6. trap "rm -rf ${WORK}" EXIT
  7. case `uname -m` in aarch64|arm64) arch="arm64";; x86_64|amd64) arch="amd64";; *) arch="";; esac
  8. [ -n "$arch" ] || exit 1
  9. [ -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}"
  10. [ $? -eq 0 ] || exit 1
  11. [ -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"
  12. [ $? -eq 0 ] || exit 1
  13. chmod -R 777 "${WORK}"
  14. cd "${WORK}"
  15. ./wgcf register --config ./wgcf-account.toml --accept-tos >/dev/null 2>&1
  16. ./wgcf generate --config ./wgcf-account.toml -p ./wgcf-profile.conf >/dev/null 2>&1
  17. cat >"./wireproxy.conf"<< EOF
  18. [Interface]
  19. `cat ./wgcf-profile.conf |grep '^PrivateKey'`
  20. `cat ./wgcf-profile.conf |grep '^Address'`
  21. DNS = 8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844
  22. `cat ./wgcf-profile.conf |grep '^MTU'`
  23. [Peer]
  24. `cat ./wgcf-profile.conf |grep '^PublicKey'`
  25. AllowedIPs = ::/0
  26. Endpoint = [2606:4700:d0::a29f:c001]:2408
  27. [Peer]
  28. `cat ./wgcf-profile.conf |grep '^PublicKey'`
  29. AllowedIPs = 0.0.0.0/0
  30. Endpoint = 162.159.192.1:2408
  31. [Socks5]
  32. BindAddress = 0.0.0.0:${PORT}
  33. `[ -n "${USER}" ] && [ -n "${PASSWORD}" ] && echo -en "Username = ${USER}\nPassword = ${PASSWORD}"`
  34. EOF
  35. ./wireproxy -c ./wireproxy.conf