mirror of
https://github.com/Kiritow/wg-ops.git
synced 2024-03-22 13:11:37 +08:00
Add Speeder support
This commit is contained in:
parent
32f1742c20
commit
b9776e9592
15
install.sh
15
install.sh
|
@ -11,6 +11,12 @@ curl -vL https://github.com/wangyu-/udp2raw-tunnel/releases/download/20200818.0/
|
||||||
tar -xvzf udp2raw.tgz udp2raw_amd64
|
tar -xvzf udp2raw.tgz udp2raw_amd64
|
||||||
chmod +x udp2raw_amd64
|
chmod +x udp2raw_amd64
|
||||||
rm udp2raw.tgz
|
rm udp2raw.tgz
|
||||||
|
|
||||||
|
curl -vL https://github.com/wangyu-/UDPspeeder/releases/download/20210116.0/speederv2_binaries.tar.gz -o udpspeeder.tgz
|
||||||
|
tar -xvzf udpspeeder.tgz speederv2_amd64
|
||||||
|
chmod +x speederv2_amd64
|
||||||
|
rm udpspeeder.tgz
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
VERIFIED_HASH="a7ce38b2c30980be4e71c3af8a9c1db8183db349c699fa6f843e67add7e6cca2"
|
VERIFIED_HASH="a7ce38b2c30980be4e71c3af8a9c1db8183db349c699fa6f843e67add7e6cca2"
|
||||||
|
@ -21,3 +27,12 @@ then
|
||||||
else
|
else
|
||||||
echo "[WARN] udp2raw hash mismatch: $TEMP_HASH. Expected: $VERIFIED_HASH"
|
echo "[WARN] udp2raw hash mismatch: $TEMP_HASH. Expected: $VERIFIED_HASH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
VERIFIED_HASH="3cf8f6c1e9baa530170368efb8a4bfcd6e75f88c2726ecbf2a75261dd1dd9fd5"
|
||||||
|
TEMP_HASH=$(sha256sum bin/speederv2_amd64 | awk '{print $1}')
|
||||||
|
if [ "$TEMP_HASH" == "$VERIFIED_HASH" ]
|
||||||
|
then
|
||||||
|
echo "[OK] speederv2 hash match: $TEMP_HASH"
|
||||||
|
else
|
||||||
|
echo "[WARN] speederv2 hash mismatch: $TEMP_HASH. Expected: $VERIFIED_HASH"
|
||||||
|
fi
|
||||||
|
|
|
@ -46,9 +46,23 @@ if op_mode in ("s", "m"):
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
|
is_enable_speeder = input("Enable UDP Speeder for this tunnel? [Y/n]: ").strip()
|
||||||
|
if not is_enable_speeder or is_enable_speeder.lower() in ('y', 'yes'):
|
||||||
|
speeder_ratio = input("Enter UDP Speeder Ratio (default to 20:10. Use 2:4 for gaming usage): ").strip()
|
||||||
|
speeder_info = {
|
||||||
|
"enable": True,
|
||||||
|
"port": 27100 + len(udp2raw_config["server"]),
|
||||||
|
"ratio": speeder_ratio
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
speeder_info = {
|
||||||
|
"enable": False
|
||||||
|
}
|
||||||
|
|
||||||
udp2raw_config["server"].append({
|
udp2raw_config["server"].append({
|
||||||
"port": udp_server_port,
|
"port": udp_server_port,
|
||||||
"password": udp_server_password
|
"password": udp_server_password,
|
||||||
|
"speeder": speeder_info
|
||||||
})
|
})
|
||||||
|
|
||||||
if not input("Add more udp2raw server? (Keep empty to finish)").strip():
|
if not input("Add more udp2raw server? (Keep empty to finish)").strip():
|
||||||
|
@ -75,10 +89,24 @@ if op_mode in ("c", "m"):
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
|
is_enable_speeder = input("Enable UDP Speeder for this tunnel? [Y/n]: ").strip()
|
||||||
|
if not is_enable_speeder or is_enable_speeder.lower() in ('y', 'yes'):
|
||||||
|
speeder_ratio = input("Enter UDP Speeder Ratio (default to 20:10. Use 2:4 for gaming usage): ").strip()
|
||||||
|
speeder_info = {
|
||||||
|
"enable": True,
|
||||||
|
"port": 28100 + len(udp2raw_config["server"]),
|
||||||
|
"ratio": speeder_ratio
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
speeder_info = {
|
||||||
|
"enable": False
|
||||||
|
}
|
||||||
|
|
||||||
udp2raw_config["client"].append({
|
udp2raw_config["client"].append({
|
||||||
"remote": udp_server_address,
|
"remote": udp_server_address,
|
||||||
"password": udp_server_password,
|
"password": udp_server_password,
|
||||||
"port": 28150 + len(udp2raw_config["client"])
|
"port": 29100 + len(udp2raw_config["client"]),
|
||||||
|
"speeder": speeder_info
|
||||||
})
|
})
|
||||||
|
|
||||||
if not input("Add more udp2raw client? (Keep empty to finish)").strip():
|
if not input("Add more udp2raw client? (Keep empty to finish)").strip():
|
||||||
|
@ -153,6 +181,7 @@ while True:
|
||||||
print("Saving to local config...")
|
print("Saving to local config...")
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
"version": 1,
|
||||||
"mode": op_mode,
|
"mode": op_mode,
|
||||||
"pubkey": wg_pubk,
|
"pubkey": wg_pubk,
|
||||||
"prikey": wg_prik,
|
"prikey": wg_prik,
|
||||||
|
|
|
@ -11,10 +11,16 @@ except Exception:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
print("[ERROR] No valid config found.")
|
print("[ERROR] No valid config found.")
|
||||||
|
|
||||||
|
|
||||||
|
if "version" not in config or int(config["version"]) < 1:
|
||||||
|
print("[WARN] Legacy version of config found. This may cause issues.")
|
||||||
|
|
||||||
|
|
||||||
op_mode = config["mode"]
|
op_mode = config["mode"]
|
||||||
udp_clients = config["udp2raw"]["client"]
|
udp_clients = config["udp2raw"]["client"]
|
||||||
udp_servers = config["udp2raw"]["server"]
|
udp_servers = config["udp2raw"]["server"]
|
||||||
|
|
||||||
|
|
||||||
print("Generating wireguard config...")
|
print("Generating wireguard config...")
|
||||||
with open("{}.conf".format(config["interface"]), "w", encoding='utf-8') as f:
|
with open("{}.conf".format(config["interface"]), "w", encoding='utf-8') as f:
|
||||||
f.write('''[Interface]
|
f.write('''[Interface]
|
||||||
|
@ -30,7 +36,13 @@ PublicKey = {}
|
||||||
AllowedIPs = {}
|
AllowedIPs = {}
|
||||||
'''.format(info["pubkey"], info["allowed"]))
|
'''.format(info["pubkey"], info["allowed"]))
|
||||||
if info["endpoint"]:
|
if info["endpoint"]:
|
||||||
f.write("Endpoint = 127.0.0.1:{}\n".format(udp_clients[int(info["endpoint"]) - 1]["port"]))
|
udp_info = udp_clients[int(info["endpoint"]) - 1]
|
||||||
|
if udp_info["speeder"]["enable"]:
|
||||||
|
# WG --> Speeder
|
||||||
|
f.write("Endpoint = 127.0.0.1:{}\n".format(udp_info["speeder"]["port"]))
|
||||||
|
else:
|
||||||
|
# WG --> Tunnel
|
||||||
|
f.write("Endpoint = 127.0.0.1:{}\n".format(udp_info["port"]))
|
||||||
if info["keepalive"]:
|
if info["keepalive"]:
|
||||||
f.write("PersistentKeepalive = {}".format(info["keepalive"]))
|
f.write("PersistentKeepalive = {}".format(info["keepalive"]))
|
||||||
|
|
||||||
|
@ -45,11 +57,27 @@ cp {}.conf /etc/wireguard/
|
||||||
tmux new-session -s tunnel -d
|
tmux new-session -s tunnel -d
|
||||||
'''.format(config["interface"]))
|
'''.format(config["interface"]))
|
||||||
for info in udp_clients:
|
for info in udp_clients:
|
||||||
|
if info["speeder"]["enable"]:
|
||||||
|
# WG --> Speeder --> RawTunnel
|
||||||
|
speeder = info["speeder"]
|
||||||
|
f.write('''tmux new-window -t tunnel -d 'bin/speederv2_amd64 -c -l127.0.0.1:{} -r 127.0.0.1:{} -f{} --mode 0' \n'''.format(speeder["port"], info["port"], speeder["ratio"]))
|
||||||
|
|
||||||
f.write('''tmux new-window -t tunnel -d 'bin/udp2raw_amd64 -c -l127.0.0.1:{} -r{} -k "{}" --raw-mode faketcp -a' \n'''.format(info["port"], info["remote"], info["password"]))
|
f.write('''tmux new-window -t tunnel -d 'bin/udp2raw_amd64 -c -l127.0.0.1:{} -r{} -k "{}" --raw-mode faketcp -a' \n'''.format(info["port"], info["remote"], info["password"]))
|
||||||
|
|
||||||
for info in udp_servers:
|
for info in udp_servers:
|
||||||
|
if info["speeder"]["enable"]:
|
||||||
|
# RawTunnel --> Speeder --> WG
|
||||||
|
speeder = info["speeder"]
|
||||||
|
f.write('''tmux new-window -t tunnel -d 'bin/speederv2_amd64 -s -l127.0.0.1:{} -r 127.0.0.1:{} -f{} --mode 0' \n'''.format(speeder["port"], config["listen"], speeder["ratio"]))
|
||||||
|
f.write('''tmux new-window -t tunnel -d 'bin/udp2raw_amd64 -s -l0.0.0.0:{} -r 127.0.0.1:{} -k "{}" --raw-mode faketcp -a' \n'''.format(info["port"], speeder["port"], info["password"]))
|
||||||
|
else:
|
||||||
|
# RawTunnel --> WG
|
||||||
f.write('''tmux new-window -t tunnel -d 'bin/udp2raw_amd64 -s -l0.0.0.0:{} -r 127.0.0.1:{} -k "{}" --raw-mode faketcp -a' \n'''.format(info["port"], config["listen"], info["password"]))
|
f.write('''tmux new-window -t tunnel -d 'bin/udp2raw_amd64 -s -l0.0.0.0:{} -r 127.0.0.1:{} -k "{}" --raw-mode faketcp -a' \n'''.format(info["port"], config["listen"], info["password"]))
|
||||||
|
|
||||||
|
# Enable BBR
|
||||||
|
f.write("sysctl net.core.default_qdisc=fq\n")
|
||||||
|
f.write("sysctl net.ipv4.tcp_congestion_control=bbr\n")
|
||||||
|
|
||||||
if op_mode in ("s", "m"):
|
if op_mode in ("s", "m"):
|
||||||
f.write("sysctl net.ipv4.ip_forward=1\n")
|
f.write("sysctl net.ipv4.ip_forward=1\n")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user