Skip to content

Commit

Permalink
Fixed: #95 #96
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Dec 16, 2018
1 parent 05a7114 commit 7308455
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
18 changes: 12 additions & 6 deletions global_setting/clean_iptables.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash

RESULT=$(iptables -nvL INPUT --line-number|grep dpt|awk '{print $1" " $14}'|sed 's/dpt://g'|sort -n -k1 -r)
echo "$RESULT" | while read LINE
do
LINE_ARRAY=($LINE)
[[ ${LINE_ARRAY[1]} && -z $(lsof -i:${LINE_ARRAY[1]}) ]] && iptables -D INPUT ${LINE_ARRAY[0]}
done
clean_iptables(){
TYPE=$1
RESULT=$(iptables -nvL $TYPE --line-number|grep :|awk -F ':' '{print $2" " $1}'|awk '{print $2" "$1}'|sort -n -k1 -r)
echo "$RESULT" | while read LINE
do
LINE_ARRAY=($LINE)
[[ ${LINE_ARRAY[1]} && -z $(lsof -i:${LINE_ARRAY[1]}) ]] && iptables -D $TYPE ${LINE_ARRAY[0]}
done
}

clean_iptables INPUT
clean_iptables OUTPUT
2 changes: 1 addition & 1 deletion global_setting/stats_ctr.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def print_stats(self):
print("流量统计开启状态才能{}统计\n".format(action_info))
continue

if len(group_list) > 1:
if group_list[-1].node_list[-1].user_number > 1:
print(profile)
schoice = input("请输入所需要{}流量的组别(字母)或者序号(数字): ".format(action_info))
else:
Expand Down
14 changes: 10 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def gen_cert(domain):
os.system(start_cmd.format(name))

def open_port():
input_cmd = "iptables -I INPUT -p {0} --dport {1} -j ACCEPT"
output_cmd = "iptables -I OUTPUT -p {0} --sport {1}"

# 自动清理没用的iptables规则
os.system("bash /usr/local/multi-v2ray/global_setting/clean_iptables.sh")

from loader import Loader

Expand All @@ -177,7 +182,8 @@ def open_port():
port_set = set([group.port for group in group_list])

for port in port_set:
cmd1="iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport " + str(port) +" -j ACCEPT"
cmd2="iptables -I INPUT -m state --state NEW -m udp -p udp --dport " + str(port) +" -j ACCEPT"
os.system(cmd1)
os.system(cmd2)
port_str = str(port)
os.system(input_cmd.format("tcp", port_str))
os.system(input_cmd.format("udp", port_str))
os.system(output_cmd.format("tcp", port_str))
os.system(output_cmd.format("udp", port_str))
2 changes: 1 addition & 1 deletion v2ray
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

SHELL_V2RAY="v2.5.3"
SHELL_V2RAY="v2.5.4"

#######color code########
RED="31m" # Error message
Expand Down

0 comments on commit 7308455

Please sign in to comment.