This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 609
/
v2ray.py
99 lines (83 loc) · 2.87 KB
/
v2ray.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
import commands
def open_port(port):
cmd = [
"iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT",
"iptables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT",
"ip6tables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT",
"ip6tables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT"
]
for x in cmd:
x = x.replace("$1", str(port))
commands.getoutput(x)
def start():
os.system("""supervisorctl start v2ray.fun""")
def stop():
os.system("""supervisorctl stop v2ray.fun""")
def write(data):
with open("/usr/local/V2ray.Fun/panel.config", "w") as f:
json.dump(data, f, indent=2)
if __name__ == '__main__':
with open("/usr/local/V2ray.Fun/panel.config") as f:
data = json.load(f)
print("欢迎使用 V2ray.Fun 面板 ---- By 雨落无声\n")
print("当前面板用户名:" + str(data['username']))
print("当前面板密码:" + str(data['password']))
print("当前面板监听端口:" + str(data['port']))
print("请输入数字选择功能:\n")
print("1. 启动面板")
print("2. 停止面板")
print("3. 重启面板")
print("4. 设置面板用户名和密码")
print("5. 设置面板SSL")
print("6. 设置面板端口")
choice = str(input("\n请选择:"))
if choice == "1":
start()
open_port(data['port'])
print("启动成功!")
elif choice == "2":
stop()
print("停止成功!")
elif choice == "3":
stop()
start()
open_port(data['port'])
print("重启成功!")
elif choice == "4":
new_username = str(raw_input("请输入新的用户名:"))
new_password = str(raw_input("请输入新的密码:"))
data['username'] = new_username
data['password'] = new_password
write(data)
stop()
start()
print("用户名密码设置成功!")
elif choice == "5":
print("提示:只有在面板开启 V2ray TLS 功能时,面板自身的SSL功能才会正常运行。\n")
print("1. 打开面板 SSL 功能")
print("2. 关闭面板 SSL 功能")
ssl_choice = str(input("请选择:"))
if ssl_choice == "1":
data['use_ssl'] = "on"
write(data)
stop()
start()
print("面板SSL已开启!")
else:
data['use_ssl'] = "off"
write(data)
stop()
start()
print("面板SSL已关闭!")
elif choice == "6":
new_port = input("请输入新的面板端口:")
data['port'] = int(new_port)
write(data)
stop()
start()
open_port(data['port'])
print("面板端口已修改!")