Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 043ec26

Browse files
committed
添加检查更新、vmess中优化websocket,增加mkcp,修复若干bug
1 parent 68e8c47 commit 043ec26

File tree

6 files changed

+327
-120
lines changed

6 files changed

+327
-120
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ V2Ray 项目地址:https://github.com/v2ray/v2ray-core
77

88
# v2rayL
99

10-
![v2rayL](http://cloud.thinker.ink/images/v2rayLlogo.png)
10+
![v2rayL](http://cloud.thinker.ink/images/857633d396d9f89cc606c0666194f45f.png)
1111

1212
v2ray linux 客户端,使用pyqt5编写GUI界面,核心基于v2ray-core
1313

@@ -19,31 +19,33 @@ v2ray linux 客户端,使用pyqt5编写GUI界面,核心基于v2ray-core
1919
- 通过`vmess://``ss://`分享链接添加配置,通过二维码添加配置
2020
- 导出配置、生成配置分享链接、生成分享二维码
2121
- 最小化至托盘、测试延时、右键菜单
22+
- 检查更新
2223
- ......
2324

25+
其中vmess支持websocket、mKcp
2426
目前程序可能存在一些bug但是没有测试出,若在使用过程中发现bug,请在issue中提交,以便改进。
2527

2628
# Usage
2729

28-
## 安装
30+
## install
2931
```
3032
① 在release中下载最新版本的install.sh
3133
```
3234
```
3335
② 运行 ./install.sh
3436
```
3537

36-
## 更新
38+
## update
3739
```
3840
① 在release中下载最新版本的update.sh
3941
```
4042
```
4143
② 运行 ./update.sh
4244
```
4345

44-
# 首页展示
46+
# Home page
4547

46-
![首页](http://cloud.thinker.ink/images/0bbd5564f4c123f24089d9134bcd6fe0.png)
48+
![首页](http://cloud.thinker.ink/images/f366165b6daced76427a6f8a89cc4168.png)
4749

4850
# License
4951

v2rayL-GUI/config.py

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,81 @@
33
# Date: 2019-08-13
44

55
conf_template = {
6-
"log":{},
7-
"dns":{},
8-
"stats":{},
9-
"inbounds":[
10-
{
11-
"port":"1080",
12-
"protocol":"socks",
13-
"settings":{
14-
"auth":"noauth",
15-
"udp": True
16-
},
17-
"tag":"in-0"
18-
}
19-
],
20-
"outbounds":[
21-
{
22-
"protocol":"",
23-
"settings":{},
24-
"tag":"out-0",
25-
"streamSettings":{}
26-
},
27-
{
28-
"tag":"direct",
29-
"protocol":"freedom",
30-
"settings":{}
6+
"dns": {
7+
"servers": [
8+
"1.1.1.1"
9+
]
10+
},
11+
"inbounds": [{
12+
"port": 1080,
13+
"protocol": "socks",
14+
"settings": {
15+
"auth": "noauth",
16+
"udp": True,
17+
"userLevel": 8
18+
},
19+
"sniffing": {
20+
"destOverride": [
21+
"http",
22+
"tls"
23+
],
24+
"enabled": True
25+
},
26+
"tag": "socks"
3127
},
3228
{
33-
"tag":"blocked",
34-
"protocol":"blackhole",
35-
"settings":{}
29+
"port": 1081,
30+
"protocol": "http",
31+
"settings": {
32+
"userLevel": 8
33+
},
34+
"tag": "http"
3635
}
3736
],
38-
"routing":{
39-
"domainStrategy":"IPOnDemand",
40-
"rules":[
37+
"log": {
38+
"loglevel": "warning"
39+
},
40+
"outbounds": [{
41+
"mux": {
42+
"enabled": False
43+
},
44+
"protocol": "",
45+
"settings": {},
46+
"streamSettings": {},
47+
"tag": "proxy"
48+
},
49+
{
50+
"protocol": "freedom",
51+
"settings": {},
52+
"tag": "direct"
53+
},
4154
{
42-
"type":"field",
43-
"ip":[
44-
"geoip:private"
45-
],
46-
"outboundTag":"direct"
55+
"protocol": "blackhole",
56+
"settings": {
57+
"response": {
58+
"type": "http"
59+
}
60+
},
61+
"tag": "block"
4762
}
48-
]
63+
],
64+
"policy": {
65+
"levels": {
66+
"8": {
67+
"connIdle": 300,
68+
"downlinkOnly": 1,
69+
"handshake": 4,
70+
"uplinkOnly": 1
71+
}
72+
},
73+
"system": {
74+
"statsInboundUplink": True,
75+
"statsInboundDownlink": True
76+
}
77+
},
78+
"routing": {
79+
"domainStrategy": "IPIfNonMatch",
80+
"rules": []
4981
},
50-
"policy":{},
51-
"reverse":{},
52-
"transport":{}
82+
"stats": {}
5383
}

v2rayL-GUI/sub2conf_api.py

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def b642conf(self, prot, tp, b64str):
4343
ret = eval(base64.b64decode(b64str).decode())
4444
region = ret['ps']
4545

46-
elif prot == "ss":
46+
elif prot == "shadowsocks":
4747
string = b64str.split("#")
4848
cf = string[0].split("@")
4949
if len(cf) == 1:
@@ -75,22 +75,49 @@ def setconf(self, region):
7575
"users": [
7676
{
7777
"id": use_conf["id"],
78-
"alterId": use_conf["aid"]
78+
"alterId": int(use_conf["aid"]),
79+
"security": "auto",
80+
"level": 8,
7981
}
8082
]
8183
})
82-
83-
conf['outbounds'][0]["streamSettings"] = {
84-
"network": use_conf["net"],
85-
"wsSettings": {
86-
"path": use_conf["path"],
87-
"headers": {
88-
"Host": use_conf['host']
84+
# webSocket 协议
85+
if use_conf["net"] == "ws":
86+
conf['outbounds'][0]["streamSettings"] = {
87+
"network": use_conf["net"],
88+
"security": "tls" if use_conf["tls"] else "",
89+
"tlssettings": {
90+
"allowInsecure": True,
91+
"serverName": use_conf["tls"]
92+
},
93+
"wssettings": {
94+
"connectionReuse": True,
95+
"headers": {
96+
"Host": use_conf['host']
97+
},
98+
"path": use_conf["path"]
8999
}
90100
}
91-
}
101+
# mKcp协议
102+
elif use_conf["net"] == "kcp":
103+
conf['outbounds'][0]["streamSettings"] = {
104+
"network": use_conf["net"],
105+
"kcpsettings": {
106+
"congestion": False,
107+
"downlinkCapacity": 100,
108+
"header": {
109+
"type": use_conf["type"] if use_conf["type"] else "none"
110+
},
111+
"mtu": 1350,
112+
"readBufferSize": 1,
113+
"tti": 50,
114+
"uplinkCapacity": 12,
115+
"writeBufferSize": 1
116+
},
117+
"security": ""
118+
}
92119

93-
elif use_conf['prot'] == "ss":
120+
elif use_conf['prot'] == "shadowsocks":
94121
conf['outbounds'][0]["protocol"] = "shadowsocks"
95122
conf['outbounds'][0]["settings"]["servers"] = list()
96123
conf['outbounds'][0]["settings"]["servers"].append({
@@ -143,7 +170,7 @@ def update(self):
143170
if ori[0] == "vmess":
144171
self.b642conf("vmess", 1, ori[1])
145172
elif ori[0] == "ss":
146-
self.b642conf("ss", 1, ori[1])
173+
self.b642conf("shadowsocks", 1, ori[1])
147174

148175
self.conf = dict(self.saved_conf['local'], **self.saved_conf['subs'])
149176

@@ -159,7 +186,7 @@ def add_conf_by_uri(self):
159186
if op[0] == "vmess":
160187
self.b642conf("vmess", 0, op[1])
161188
elif op[0] == "ss":
162-
self.b642conf("ss", 0, op[1])
189+
self.b642conf("shadowsocks", 0, op[1])
163190
else:
164191
raise MyException("无法解析的链接格式")
165192
except Exception as e:

v2rayL-GUI/v2rayL_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def disconnect(self):
6565
else:
6666
raise MyException("服务未开启,无需断开连接.")
6767
except Exception as e:
68-
raise MyException(e)
68+
raise MyException(e.args[0])
6969

7070
def update(self, url):
7171
if url: # 如果存在订阅地址

v2rayL-GUI/v2rayL_threads.py

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# Date: 2019-08-13
44

55
from PyQt5.QtCore import QThread, pyqtSignal
6+
from PyQt5.QtWidgets import QMessageBox
67
from sub2conf_api import MyException
8+
import subprocess
9+
import requests
10+
711

812

913
class ConnectThread(QThread):
@@ -23,7 +27,7 @@ def run(self):
2327
try:
2428
row = self.tableView.currentIndex().row()
2529
region = self.tableView.model().item(row, 0).text()
26-
except Exception as e:
30+
except AttributeError:
2731
self.sinOut.emit(("conn", "@@Fail@@", "未选中配置无法连接,请导入配置后再次连接", None))
2832
else:
2933
try:
@@ -115,5 +119,70 @@ def run(self):
115119
ret = self.v2rayL.ping(addr)
116120
except MyException as e:
117121
self.sinOut.emit(("ping", "@@Fail@@", e.args[0], None))
122+
except AttributeError:
123+
self.sinOut.emit(("ping", "@@Fail@@", "请选择需要测试的配置.", None))
118124
else:
119-
self.sinOut.emit(("ping", "@@OK@@", ret.strip(), None))
125+
self.sinOut.emit(("ping", "@@OK@@", ret.strip(), None))
126+
127+
128+
class CheckUpdateThread(QThread):
129+
"""
130+
测试延时线程
131+
"""
132+
sinOut = pyqtSignal(tuple)
133+
134+
def __init__(self, version=None, parent=None):
135+
super(CheckUpdateThread, self).__init__(parent)
136+
self.version = version
137+
138+
def __del__(self):
139+
# 线程状态改变与线程终止
140+
self.wait()
141+
142+
def run(self):
143+
update_url = "https://api.github.com/repos/jiangxufeng/v2rayL/releases/latest"
144+
try:
145+
req = requests.get(update_url)
146+
if req.status_code != 200:
147+
self.sinOut.emit(("ckud", "@@Fail@@", "网络错误,请检查网络连接或稍后再试.", None))
148+
else:
149+
latest = req.json()['tag_name']
150+
if latest == self.version:
151+
self.sinOut.emit(("ckud", "@@OK@@", "当前版本已是最新版本.", None))
152+
else:
153+
self.sinOut.emit(("ckud", "@@OK@@", "正在后台进行更新..", req))
154+
except Exception as e:
155+
self.sinOut.emit(("ckud", "@@Fail@@", "网络错误,请检查网络连接或稍后再试."+e.args[0], None))
156+
157+
158+
class VersionUpdateThread(QThread):
159+
"""
160+
测试延时线程
161+
"""
162+
sinOut = pyqtSignal(tuple)
163+
164+
def __init__(self, update_url=None, parent=None):
165+
super(VersionUpdateThread, self).__init__(parent)
166+
self.url = update_url
167+
168+
def __del__(self):
169+
# 线程状态改变与线程终止
170+
self.wait()
171+
172+
def run(self):
173+
try:
174+
req = requests.get(self.url)
175+
if req.status_code != 200:
176+
self.sinOut.emit(("vrud", "@@Fail@@", "网络错误,请检查网络连接或稍后再试.", None))
177+
else:
178+
print(1)
179+
with open("/etc/v2rayL/update.sh", 'w') as f:
180+
f.write(req.text)
181+
182+
subprocess.call(["chmod +x /etc/v2rayL/update.sh && /etc/v2rayL/update.sh"], shell=True)
183+
184+
self.sinOut.emit(("vrud", "@@OK@@", "更新完成, 重启程序生效.", None))
185+
186+
except Exception as e:
187+
self.sinOut.emit(("vrud", "@@Fail@@", "网络错误,请检查网络连接或稍后再试."+e.args[0], None))
188+

0 commit comments

Comments
 (0)