Add PublicIP display. Fix generator

master
Kirigaya Kazuto 2021-07-13 15:16:10 +08:00
parent 8010b6481e
commit 2219bc0b74
4 changed files with 25 additions and 5 deletions

View File

@ -2,6 +2,7 @@
export WG_MYPRIK=$(wg genkey)
export WG_MYPUBK=$(echo $WG_MYPRIK | wg pubkey)
export WG_PUBLICIP=$(curl ident.me)
python3 tool_create.py
python3 tool_generate.py

View File

@ -9,6 +9,7 @@ cd bin
curl -vL https://github.com/wangyu-/udp2raw-tunnel/releases/download/20200818.0/udp2raw_binaries.tar.gz -o udp2raw.tgz
tar -xvzf udp2raw.tgz udp2raw_amd64
chmod +x udp2raw_amd64
rm udp2raw.tgz
cd ..

View File

@ -88,9 +88,21 @@ if op_mode in ("c", "m"):
wg_prik = os.getenv("WG_MYPRIK")
wg_pubk = os.getenv("WG_MYPUBK")
wg_mtu = "1000"
print("====== Your Wireguard Public Key ======")
print(wg_pubk)
print("=======================================")
wg_public_ip = os.getenv("WG_PUBLICIP")
print('''
====== Your Wireguard Public Key ======
{}
======= Your Public IP Address ========
{}
=======================================
'''.format(wg_pubk, wg_public_ip))
ifname = input("Input new wireguard interface name (wg0):").strip() or "wg0"
listen_port = input("Input new wireguard listen port (51820): ").strip() or "51820"

View File

@ -10,6 +10,7 @@ except Exception:
print(traceback.format_exc())
print("[ERROR] No valid config found.")
op_mode = config["mode"]
udp_clients = config["udp2raw"]["client"]
udp_servers = config["udp2raw"]["server"]
@ -42,11 +43,16 @@ cp {}.conf /etc/wireguard/
tmux new-session -s tunnel -d
'''.format(config["interface"]))
for info in udp_clients:
f.write('''tmux new-window -t tunnel -d './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:
f.write('''tmux new-window -t tunnel -d './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"]))
if op_mode in ("s", "m"):
f.write("sysctl net.ipv4.ip_forward=1\n")
f.write('''wg-quick up {}
tmux attach-session -t tunnel
'''.format(config["interface"]))
print("[OK] Config generated. Be sure to configure and enable UFW (or any other firewall) before start.")