فهرست منبع

2019年 猪事顺利,青春永猪,猪圆玉润,猪笼入水---八面来财

hongwenjun 6 سال پیش
والد
کامیت
d0ac23c958
9فایلهای تغییر یافته به همراه30 افزوده شده و 57 حذف شده
  1. 2 3
      README.md
  2. 5 0
      Wireguard/README.md
  3. 1 32
      Wireguard/auto-add-routes.md
  4. BIN
      Wireguard/route.zip
  5. 1 1
      Wireguard/wg5clients.sh
  6. 2 4
      Wireguard/wg_clients.sh
  7. 19 17
      Wireguard/wgmtu.sh
  8. BIN
      img/wgmtu.png
  9. BIN
      img/zfb_hb.png

+ 2 - 3
README.md

@@ -11,9 +11,8 @@ yum install -y wget && \
 wget https://raw.githubusercontent.com/atrandys/wireguard/master/wireguard_install.sh \
 && chmod +x wireguard_install.sh && ./wireguard_install.sh
 ```
-
-### 猪事顺利,青春永猪,猪圆玉润,猪笼入水---八面来财
-![](https://raw.githubusercontent.com/hongwenjun/vps_setup/master/img/zfb_hb.png)
+### 增加功能  <<  添加/删除 WireGuard Peer 客户端管理 >>
+![](https://raw.githubusercontent.com/hongwenjun/vps_setup/master/img/wgmtu.png)
 
 ### 一键安装wireguard 参考演示视频集合
 

+ 5 - 0
Wireguard/README.md

@@ -43,5 +43,10 @@ AllowedIPs = 10.0.0.3/32
 ```
 
 ### 中国白名单分流  route.zip
+为使用各类全局代理VPN的windows用户提供国内国外IP的分流服务。原理是将国内IP写进系统路由表,路由表以外的IP走VPN代理。
+
+[https://github.com/hongwenjun/china_ip_list](https://github.com/hongwenjun/china_ip_list)
+
+
 ### TunSafe-TAP 虚拟网卡驱动  TunSafe-TAP-9.21.2.exe
 ### TunSafe 客户端 TunSafe-1.4.exe

+ 1 - 32
Wireguard/auto-add-routes.md

@@ -3,35 +3,4 @@
 ## 介绍
 为使用各类全局代理VPN的windows用户提供国内国外IP的分流服务。原理是将国内IP写进系统路由表,路由表以外的IP走VPN代理。
 
-## 文件说明:
-
-add.txt和del.txt为写入和删除时使用的路由表;
-
-routes-up.bat和routes-down.bat为Tunsafe在连接前和断开后调用的写入/删除路由表的批处理文件。通过Tunsafe的PreUp和PostDown命令调用。
-
-cmroute.dll会被上述两个批处理文件调用,作用是秒载/秒删路由表。即使有数千条路由表也能秒载入,秒删除。
-
-## 使用方法
-
-### Wireguard
-#### 1. 下载最新版本Tunsafe,建议使用带rc的版本。
-
-#### 2. 开启Tunsafe的Pre/Post命令功能。在"Option"选择"Allow Pre/Post Commands"
-
-#### 3. 下载[route.zip](https://raw.githubusercontent.com/lmc999/auto-add-routes/master/route.zip)解压到Tunsafe安装目录。
-
-#### 4. Wireguard客户端配置文件加入PreUp,Postdown命令调用批处理文件。
-
-假设你的Tunsafe安装在D盘abc目录下,你需要在客户端配置文件添加以下两条命令
-
-PreUp = start D:\abc\TunSafe\route\routes-up.bat
-
-PostDown = start D:\abc\TunSafe\route\routes-down.bat
-
-设置实例请参考[sample.conf](https://github.com/lmc999/auto-add-routes/blob/master/sample.conf)
-
-#### 5. 正常使用Tunsafe点击connect就会调用routes-up.bat将国内IP写进系统路由表,断开disconnect则会调用routes-down.bat删除路由表。
-连接成功后可上 http://ip111.cn/ 测试自己的IP。
-
-### OpenVPN
-#### TODO
+[https://github.com/hongwenjun/china_ip_list](https://github.com/hongwenjun/china_ip_list)

BIN
Wireguard/route.zip


+ 1 - 1
Wireguard/wg5clients.sh

@@ -56,7 +56,7 @@ port=$(rand 1000 60000)
 mtu=1420
 host=$(hostname -s)
 
-ip_list=(2 8 98 88 188 118 158 198 168 9)
+ip_list=(2 5 8 178 188 118 158 198 168 9)
 
 # 获得服务器ip,自动获取
 if [ ! -f '/usr/bin/curl' ]; then

+ 2 - 4
Wireguard/wg_clients.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # 服务器 IP 和 端口
-port=$(wg | grep 'listening port:' | awk '{print $3}')
+port=$(wg show wg0 listen-port)
 serverip=$(curl -4 ip.sb)
 host=$(hostname -s)
 
@@ -15,10 +15,8 @@ Info="${Green}[信息]${Font}"  &&  OK="${Green}[OK]${Font}"  &&  Error="${Red}[
 cd /etc/wireguard
 cp wg0.conf  conf.wg0.bak
 
-echo -e   "${RedBG}重置 WireGuard 客户端配置数量,方便修改过端口或者机场大佬${Font}"
-echo -e "${GreenBG}    开源项目:https://github.com/hongwenjun/vps_setup    ${Font}"
+echo -e   "${RedBG}  重置 WireGuard 客户端 Peer 数量  ${Font}"
 echo
-
 echo -e "${GreenBG} 请输入客户端配置数量 ${Font}"
 read -p "请输入数字(3--218): " num_x
 

+ 19 - 17
Wireguard/wgmtu.sh

@@ -30,9 +30,9 @@ setport(){
 
     if [[ ${num} -ge 100 ]] && [[ ${num} -le 60000 ]]; then
        port=$num
-       wg-quick down wg0
-       sed -i "s/ListenPort = .*$/ListenPort = ${port}/g"  /etc/wireguard/wg0.conf
-       wg-quick up wg0
+       wg set wg0 listen-port $port
+       wg-quick save wg0
+
        echo -e "${RedBG}    端口号已经修改, 客户端请手工修改!  ${Font}"
     else
        echo -e "${RedBG}    没有修改端口号!    ${Font}"
@@ -96,19 +96,19 @@ scp_conf(){
     wg-quick up wg0     >/dev/null 2>&1
     echo -e "${RedBG}    我真不知道WG服务器端是否已经使用源vps的配置启动!    ${Font}"
 
-    if [ ! -f '/usr/bin/tmux' ]; then
+    if [ ! -f '~/.tmux.conf' ]; then
         get_tools_conf
     fi
 }
 
 #  隐藏功能开放: 一键脚本全家桶
 onekey_plus(){
-    echo -e "${RedBG}           一键安装设置全家桶    by 蘭雅sRGB             ${Font}"
+    echo -e "${SkyBlue}           一键安装设置全家桶    by 蘭雅sRGB             ${Font}"
     cat  <<EOF
   # 下载 IPTABLES 设置防火墙规则 脚本 By 蘭雅sRGB
   wget -qO safe_iptables.sh git.io/fhUSe && bash safe_iptables.sh
 
-  #  Google Cloud Platform GCP实例开启密码与root用户登陆
+  # Google Cloud Platform GCP实例开启密码与root用户登陆
   wget -qO- git.io/fpQWf | bash
 
   # 一键安装 vnstat 流量检测   by 蘭雅sRGB
@@ -142,7 +142,7 @@ onekey_plus(){
   cat wg_vultr_5.conf  | qrencode -o- -t utf8
 
 EOF
-    echo -e "${GreenBG}    开源项目:https://github.com/hongwenjun/vps_setup    ${Font}"
+    echo -e "${SkyBlue}    开源项目:https://github.com/hongwenjun/vps_setup    ${Font}"
 }
 
 safe_iptables(){
@@ -183,7 +183,7 @@ rc-local_remove(){
 }
 
 update_remove_menu(){
-    echo -e "${RedBG}   更新 或卸载 WireGuard服务端和Udp2Raw 子菜单  ${Font}"
+    echo -e "${RedBG}   更新/卸载 WireGuard服务端和Udp2Raw   ${Font}"
     echo -e "${Green}>  1. 更新 WireGuard 服务端"
     echo -e ">  2. 卸载 WireGuard 服务端"
     echo -e ">  3. 卸载 Udp2Raw 服务"
@@ -208,7 +208,7 @@ update_remove_menu(){
         esac
 }
 
-# 删除最末尾的peer
+# 删除末尾的Peer
 del_last_peer(){
     peer_key=$(wg show wg0 allowed-ips  | tail -1 | awk '{print $1}')
     wg set wg0 peer $peer_key remove
@@ -236,6 +236,7 @@ display_peer(){
     done
 }
 
+# 选择删除Peer客户端
 del_peer(){
     display_peer
     echo
@@ -275,7 +276,7 @@ Address = $ip/24
 DNS = 8.8.8.8
 
 [Peer]
-PublicKey = $(cat spublickey)
+PublicKey = $(wg show wg0 public-key)
 Endpoint = $serverip:$port
 AllowedIPs = 0.0.0.0/0, ::0/0
 PersistentKeepalive = 25
@@ -293,13 +294,13 @@ EOF
 }
 
 wg_clients_menu(){
-    echo -e "${RedBG}   添加/删除 WireGuard 客户端配置  子菜单  ${Font}"
-    echo -e "${Green}>  1. 添加一个 WireGuard 客户端配置"
-    echo -e ">  2. 删除末尾 WireGuard 客户端配置"
-    echo -e ">  3. 指定删除 WireGuard 客户端配置"
+    echo -e "${RedBG}   添加/删除 WireGuard Peer 客户端管理  ${Font}"
+    echo -e "${Green}>  1. 添加一个 WireGuard Peer 客户端配置"
+    echo -e ">  2. 删除末尾 WireGuard Peer 客户端配置"
+    echo -e ">  3. 指定删除 WireGuard Peer 客户端配置"
     echo    "------------------------------------------------------"
-    echo -e ">  4. 退出"
-    echo -e ">  5.${RedBG} 重置 WireGuard 客户端配置和数量 ${Font}"
+    echo -e "${SkyBlue}>  4. 退出"
+    echo -e ">  5.${RedBG} 重置 WireGuard 客户端 Peer 数量 ${Font}"
     echo
     read -p "请输入数字(1-5):" num_x
     case "$num_x" in
@@ -313,6 +314,7 @@ wg_clients_menu(){
         del_peer
         ;;
         4)
+        display_peer
         exit 1
         ;;
         5)
@@ -335,7 +337,7 @@ start_menu(){
     echo -e ">  3. 修改 WireGuard 端口号"
     echo -e ">  4. 安装 WireGuard+Speeder+Udp2Raw 和 SS+Kcp+Udp2RAW 一键脚本"
     echo    "----------------------------------------------------------"
-    echo -e "${SkyBlue}>  5. 添加/删除 WireGuard 客户端配置"
+    echo -e "${SkyBlue}>  5. 添加/删除 WireGuard Peer 客户端管理"
     echo -e ">  6. 更新/卸载 WireGuard服务端和Udp2Raw"
     echo -e ">  7. vps_setup 一键脚本全家桶大礼包"
     echo -e ">  8. ${RedBG}  小白一键设置防火墙  ${Font}"

BIN
img/wgmtu.png


BIN
img/zfb_hb.png