Skip to content

Commit e9a12de

Browse files
committed
Support IPv6
1 parent 152e48e commit e9a12de

File tree

19 files changed

+113
-52
lines changed

19 files changed

+113
-52
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## [v3.7.4](https://github.com/Jrohy/multi-v2ray/releases/tag/v3.7.4)(2019-11-28)
4+
- 测试支持纯ipv6 vps, 安装脚本路径更换
5+
36
## [v3.7.3](https://github.com/Jrohy/multi-v2ray/releases/tag/v3.7.3)(2019-11-17)
47
- 添加完整的docker功能, 包括实现容器内iptables流量统计、证书申请、命令补全
58
实现iptables流量统计起容器时必须加入--privileged

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ V2ray多用户管理脚本,向导式管理[新增|删除|修改]传输协议
2424
- [x] 支持范围端口修改
2525
- [x] 支持程序和**命令行参数**管理控制
2626
- [x] 支持docker部署
27+
- [x] 支持纯ipv6 vps
2728
- [x] 禁止BT
2829

2930
## 功能
@@ -55,17 +56,17 @@ V2ray多用户管理脚本,向导式管理[新增|删除|修改]传输协议
5556

5657
## 安装命令
5758
```
58-
source <(curl -sL https://git.io/fNgqx) --zh
59+
source <(curl -sL https://multi.netlify.com/v2ray.sh) --zh
5960
```
6061

6162
## 升级命令(保留配置文件更新)
6263
```
63-
source <(curl -sL https://git.io/fNgqx) -k
64+
source <(curl -sL https://multi.netlify.com/v2ray.sh) -k
6465
```
6566

6667
## 卸载命令
6768
```
68-
source <(curl -sL https://git.io/fNgqx) --remove
69+
source <(curl -sL https://multi.netlify.com/v2ray.sh) --remove
6970
```
7071

7172
## 命令行参数

README_EN.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ a tool to manage v2ray config json, support multiple user && group manage
1313
- Command line to manage
1414
- Multiple user && port manage
1515
- Cloudcflare cdn mode
16+
- Support pure ipv6 VPS
1617
- Support Docker
1718
- Dynamic port
1819
- Ban bittorrent
@@ -38,17 +39,17 @@ a tool to manage v2ray config json, support multiple user && group manage
3839
## How To Use
3940
new install
4041
```
41-
source <(curl -sL https://git.io/fNgqx)
42+
source <(curl -sL https://v2rays.netlify.com/install.sh)
4243
```
4344

4445
keep profile to update
4546
```
46-
source <(curl -sL https://git.io/fNgqx) -k
47+
source <(curl -sL https://v2rays.netlify.com/install.sh) -k
4748
```
4849

4950
uninstall
5051
```
51-
source <(curl -sL https://git.io/fNgqx) --remove
52+
source <(curl -sL https://v2rays.netlify.com/install.sh) --remove
5253
```
5354

5455
## Command Line

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ FROM alpine:latest
66

77
LABEL maintainer "Jrohy <[email protected]>"
88

9-
ENV COMPLETION_FILE "/usr/share/bash-completion/completions/v2ray.bash"
9+
ENV COMPLETION_FILE "/usr/share/bash-completion/completions/v2ray"
1010

11-
ENV SOURCE_COMPLETION_FILE "https://raw.githubusercontent.com/Jrohy/multi-v2ray/master/v2ray.bash"
11+
ENV SOURCE_COMPLETION_FILE "https://multi.netlify.com/v2ray"
1212

1313
COPY --from=builder /usr/bin/v2ray/v2ray /usr/bin/v2ray/
1414
COPY --from=builder /usr/bin/v2ray/v2ctl /usr/bin/v2ray/

v2ray.bash renamed to v2ray

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# bash completion for v2ray -*- shell-script -*-
1+
# bash completion for v2ray
22
function _auto_tab() {
33
local options_array=("start" "stop" "restart" "status" "update" "update.sh" "add" "del" "info" "port" "tls" "tfo" "stream" "iptables" "cdn" "stats" "clean" "log" "new" "-h" "-v")
44
local add_array=("wechat" "utp" "srtp" "dtls" "wireguard" "socks" "mtproto" "ss")
5-
local cur pre
5+
local cur prev
66

77
COMPREPLY=()
88
cur="${COMP_WORDS[COMP_CWORD]}"

multi-v2ray.sh renamed to v2ray.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ REMOVE=0
2121

2222
CHINESE=0
2323

24-
[[ `curl -s icanhazip.com` =~ ":" ]] && NETWORK=1
25-
26-
if [[ $NETWORK == 0 ]];then
27-
BASE_SOURCE_PATH="https://raw.githubusercontent.com/Jrohy/multi-v2ray/master"
28-
else
29-
BASE_SOURCE_PATH="https://v2rays.netlify.com"
30-
fi
24+
BASE_SOURCE_PATH="https://multi.netlify.com"
3125

3226
CLEAN_IPTABLES_SHELL="$BASE_SOURCE_PATH/v2ray_util/global_setting/clean_iptables.sh"
3327

34-
BASH_COMPLETION_SHELL="$BASE_SOURCE_PATH/v2ray.bash"
28+
BASH_COMPLETION_SHELL="$BASE_SOURCE_PATH/v2ray"
3529

3630
UTIL_CFG="$BASE_SOURCE_PATH/v2ray_util/util_core/util.cfg"
3731

@@ -101,6 +95,7 @@ removeV2Ray() {
10195
#卸载multi-v2ray
10296
pip uninstall v2ray_util -y
10397
rm -rf /usr/share/bash-completion/completions/v2ray.bash >/dev/null 2>&1
98+
rm -rf /usr/share/bash-completion/completions/v2ray >/dev/null 2>&1
10499
rm -rf /etc/bash_completion.d/v2ray.bash >/dev/null 2>&1
105100
rm -rf /usr/local/bin/v2ray >/dev/null 2>&1
106101
rm -rf /etc/v2ray_util >/dev/null 2>&1
@@ -131,6 +126,14 @@ closeSELinux() {
131126
fi
132127
}
133128

129+
judgeNetwork() {
130+
curl http://api.ipify.org &>/dev/null
131+
if [[ $? != 0 ]];then
132+
[[ `curl -s icanhazip.com` =~ ":" ]] && NETWORK=1
133+
fi
134+
export NETWORK=$NETWORK
135+
}
136+
134137
checkSys() {
135138
#检查是否为Root
136139
[ $(id -u) != "0" ] && { colorEcho ${RED} "Error: You must be root to run this script"; exit 1; }
@@ -180,6 +183,8 @@ installDependent(){
180183

181184
#设置定时升级任务
182185
planUpdate(){
186+
[[ $NETWORK == 1 ]] && return
187+
183188
if [[ $CHINESE == 1 ]];then
184189
#计算北京时间早上3点时VPS的实际时间
185190
ORIGIN_TIME_ZONE=$(date -R|awk '{printf"%d",$6}')
@@ -237,12 +242,13 @@ updateProject() {
237242
rm -f /usr/local/bin/v2ray >/dev/null 2>&1
238243
ln -s $(which v2ray-util) /usr/local/bin/v2ray
239244

240-
#移除旧路径v2ray bash_completion脚本
245+
#移除旧的v2ray bash_completion脚本
241246
[[ -e /etc/bash_completion.d/v2ray.bash ]] && rm -f /etc/bash_completion.d/v2ray.bash
247+
[[ -e /usr/share/bash-completion/completions/v2ray.bash ]] && rm -f /usr/share/bash-completion/completions/v2ray.bash
242248

243249
#更新v2ray bash_completion脚本
244-
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/v2ray.bash
245-
[[ -z $(echo $SHELL|grep zsh) ]] && source /usr/share/bash-completion/completions/v2ray.bash
250+
curl $BASH_COMPLETION_SHELL > /usr/share/bash-completion/completions/v2ray
251+
[[ -z $(echo $SHELL|grep zsh) ]] && source /usr/share/bash-completion/completions/v2ray
246252

247253
#安装/更新V2ray主程序
248254
if [[ $NETWORK == 1 ]];then
@@ -302,6 +308,7 @@ installFinish() {
302308

303309

304310
main() {
311+
judgeNetwork
305312

306313
[[ ${HELP} == 1 ]] && help && return
307314

v2ray_util/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '3.7.4b4'
1+
__version__ = '3.7.4'
22

33
from .util_core.trans import _

v2ray_util/global_setting/calcul_traffic.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/bin/bash
22
PORT=$1
33

4+
NETWORK=$2
5+
46
[[ $# == 0 ]] && exit 1
57

6-
INPUT_TRAFFIC=$(iptables -nvL INPUT -x|grep $PORT|awk '{sum += $2};END {printf("%.0f\n",sum)}')
8+
if [[ $NETWORK ]];then
9+
INPUT_TRAFFIC=$(ip6tables -nvL INPUT -x|grep $PORT|awk '{sum += $2};END {printf("%.0f\n",sum)}')
10+
11+
OUTPUT_TRAFFIC=$(ip6tables -nvL OUTPUT -x|grep $PORT|awk '{sum += $2};END {printf("%.0f\n",sum)}')
12+
else
13+
INPUT_TRAFFIC=$(iptables -nvL INPUT -x|grep $PORT|awk '{sum += $2};END {printf("%.0f\n",sum)}')
714

8-
OUTPUT_TRAFFIC=$(iptables -nvL OUTPUT -x|grep $PORT|awk '{sum += $2};END {printf("%.0f\n",sum)}')
15+
OUTPUT_TRAFFIC=$(iptables -nvL OUTPUT -x|grep $PORT|awk '{sum += $2};END {printf("%.0f\n",sum)}')
16+
fi
917

1018
if [[ $INPUT_TRAFFIC && $OUTPUT_TRAFFIC ]]; then
1119
TOTAL_TRAFFIC=`expr $INPUT_TRAFFIC + $OUTPUT_TRAFFIC`

v2ray_util/global_setting/clean_iptables.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
#!/bin/bash
22
clean_old_iptables(){
33
local TYPE=$1
4-
RESULT=$(iptables -nvL $TYPE --line-number|grep state|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
4+
if [[ $NETWORK == 1 ]];then
5+
RESULT=$(ip6tables -nvL $TYPE --line-number|grep state|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
6+
else
7+
RESULT=$(iptables -nvL $TYPE --line-number|grep state|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
8+
fi
59
echo "$RESULT" | while read LINE
610
do
711
LINE_ARRAY=($LINE)
812
if [[ ${LINE_ARRAY[1]} && $(lsof -i:${LINE_ARRAY[1]}|grep v2ray) ]];then
9-
iptables -D $TYPE ${LINE_ARRAY[0]}
13+
[[ $NETWORK == 1 ]] && ip6tables -D $TYPE ${LINE_ARRAY[0]} || iptables -D $TYPE ${LINE_ARRAY[0]}
1014
fi
1115
done
1216
}
1317

1418
clean_iptables(){
1519
local TYPE=$1
16-
RESULT=$(iptables -nvL $TYPE --line-number|grep :|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
20+
if [[ $NETWORK == 1 ]];then
21+
RESULT=$(ip6tables -nvL $TYPE --line-number|grep :|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
22+
else
23+
RESULT=$(iptables -nvL $TYPE --line-number|grep :|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
24+
fi
1725
echo "$RESULT" | while read LINE
1826
do
1927
LINE_ARRAY=($LINE)
20-
[[ ${LINE_ARRAY[1]} && -z $(lsof -i:${LINE_ARRAY[1]}) ]] && iptables -D $TYPE ${LINE_ARRAY[0]}
28+
if [[ ${LINE_ARRAY[1]} && -z $(lsof -i:${LINE_ARRAY[1]}) ]];then
29+
[[ $NETWORK == 1 ]] && ip6tables -D $TYPE ${LINE_ARRAY[0]} || iptables -D $TYPE ${LINE_ARRAY[0]}
30+
fi
2131
done
2232
}
2333

v2ray_util/global_setting/clean_traffic.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
#!/bin/bash
22
PORT=$1
33

4+
NETWORK=$2
5+
46
[[ $# == 0 ]] && exit 1
57

68
clean_traffic(){
79
local TYPE=$1
8-
RESULT=$(iptables -nvL $TYPE --line-numbers|grep -w "$PORT"|awk '{print $1}')
10+
if [[ $NETWORK ]];then
11+
RESULT=$(ip6tables -nvL $TYPE --line-numbers|grep -w "$PORT"|awk '{print $1}')
12+
else
13+
RESULT=$(iptables -nvL $TYPE --line-numbers|grep -w "$PORT"|awk '{print $1}')
14+
fi
915
echo "$RESULT" | while read LINE
1016
do
11-
[[ ${LINE} ]] && iptables -Z $TYPE $LINE
17+
if [[ ${LINE} ]];then
18+
[[ $NETWORK ]] && ip6tables -Z $TYPE $LINE || iptables -Z $TYPE $LINE
19+
fi
1220
done
1321
}
1422

v2ray_util/global_setting/iptables_ctr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def manage():
2727
choice = readchar(_("please select: "))
2828
if choice == "1":
2929
print("")
30+
ipv6 = True if profile.network == "ipv6" else False
3031
for group in group_list:
31-
print(calcul_iptables_traffic(group.port))
32+
print(calcul_iptables_traffic(group.port, ipv6))
3233
print("")
3334

3435
elif choice == "2":

v2ray_util/global_setting/update_timer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import time
55
from ..util_core.config import Config
6+
from ..util_core.loader import Loader
67
from ..util_core.utils import ColorStr, readchar
78

89
def restartCron():
@@ -16,6 +17,9 @@ def restartCron():
1617
os.system("systemctl restart cron >/dev/null 2>&1")
1718

1819
def planUpdate():
20+
if Loader().profile.network == "ipv6":
21+
print(ColorStr.yellow("ipv6 not support!"))
22+
return
1923
if Config().get_data("lang") == "zh":
2024
origin_time_zone = int(time.strftime("%z", time.gmtime())[0:-2])
2125
beijing_time_zone, beijing_update_time = 8, 3
431 Bytes
Binary file not shown.

v2ray_util/locale_i18n/zh_CH/LC_MESSAGES/lang.po

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ msgstr "是否存在"
201201
msgid "clean v2ray log success!"
202202
msgstr "清理v2ray日志成功!"
203203

204+
msgid "ipv6 network not support update v2ray online, please manual donwload v2ray to update!"
205+
msgstr "ipv6 网络不支持v2ray的在线更新, 请手动下载v2ray来更新!"
206+
207+
msgid "download v2ray-linux-xx.zip and run 'bash <(curl -L -s https://install.direct/go.sh) -l v2ray-linux-xx.zip' to update"
208+
msgstr "下载v2ray-linux-xx.zip包然后运行 'bash <(curl -L -s https://install.direct/go.sh) -l v2ray-linux-xx.zip' 来更新"
209+
204210
msgid "check v2ray no install, auto install v2ray.."
205211
msgstr "检测到本机没安装v2ray, 正在自动安装.."
206212

v2ray_util/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def updateSh():
7171
if os.path.exists("/.dockerenv"):
7272
print(ColorStr.yellow("docker run not support update!"))
7373
else:
74-
subprocess.Popen("curl -Ls https://git.io/fNgqx -o temp.sh", shell=True).wait()
74+
subprocess.Popen("curl -Ls https://multi.netlify.com/v2ray.sh -o temp.sh", shell=True).wait()
7575
subprocess.Popen("bash temp.sh -k && rm -f temp.sh", shell=True).wait()
7676

7777
def parse_arg():

v2ray_util/util_core/loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def load_profile(self):
2121
self.profile = pickle.load(reader)
2222
if os.path.getmtime(self.profile.path) != self.profile.modify_time:
2323
raise ValueError
24+
if not hasattr(self.profile, "network"):
25+
raise ValueError
2426
else:
2527
raise FileNotFoundError
2628
except Exception:

v2ray_util/util_core/profile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self):
2323
self.stats = None
2424
self.ban_bt = False
2525
self.user_number = 0
26+
self.network = "ipv4"
2627
self.modify_time = os.path.getmtime(self.path)
2728
self.read_json()
2829

@@ -63,6 +64,9 @@ def read_json(self):
6364

6465
local_ip = get_ip()
6566

67+
if ":" in local_ip:
68+
self.network = "ipv6"
69+
6670
group_ascii = 64 # before 'A' ascii code
6771
for index, json_part in enumerate(conf_inbounds):
6872
group = self.parse_group(json_part, index, local_ip)

0 commit comments

Comments
 (0)