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

Commit

Permalink
修复存在部分情况下中文名称url编码的情况,新增同时添加多个配置,恢复测试延时
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangxufeng committed Sep 9, 2019
1 parent 73a8979 commit 2345856
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 148 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ v2ray linux 客户端,使用pyqt5编写GUI界面,核心基于v2ray-core
- 支持协议:vmess、shadowsocks
- 通过`vmess://``ss://`分享链接添加配置,通过二维码添加配置
- 导出配置、生成配置分享链接、生成分享二维码
- 最小化至托盘、检查更新
- 最小化至托盘、测试延时、检查更新
- ......

其中vmess支持websocket、mKcp
Expand Down
143 changes: 103 additions & 40 deletions v2rayL-GUI/new_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ def init_ui(self):
self.right_bar_layout.addWidget(self.v2rayL_icon, 0, 0, 1, 4, Qt.AlignRight)
self.right_bar_layout.addWidget(self.v2rayL_label, 0, 4, 1, 5, Qt.AlignLeft)

# self.right_one_widget = QWidget()
# self.right_one_layout = QGridLayout()
# self.right_one_widget.setLayout(self.right_one_layout)

self.right_up_layout.addWidget(self.right_bar_widget, 0, 0, 1, 9)
# self.right_layout.addWidget(self.right_one_widget, 1, 0, 8, 9)

Expand Down Expand Up @@ -308,27 +304,37 @@ def init_ui(self):
self.system_setting_widget = QWidget()
self.help_widget = QWidget()
self.first_widget = QWidget()
# self.settings1_layout = QGridLayout()
# self.settings1_widget.setLayout(self.settings1_layout)
#
# self.label_peizhi = QLabel("配置")

# 配置页面
self.config_setting_ui = Ui_Setting1_Form()
self.config_setting_ui.setupUi(self.config_setting_widget)
self.right_down_layout.addWidget(self.config_setting_widget)


# 系统设置页面
self.system_setting_ui = Ui_SystemSettings()
self.system_setting_ui.setupUi(self.system_setting_widget)
self.right_down_layout.addWidget(self.system_setting_widget)

# 版本说明页面
self.help_ui = Ui_HelpUi()
self.help_ui.setupUi(self.help_widget)
self.right_down_layout.addWidget(self.help_widget)

# 主页连接页面
self.first_ui = Ui_FirstPage()
self.first_ui.setupUi(self.first_widget)
self.right_down_layout.addWidget(self.first_widget)

# 分享配置窗口
self.share_ui = QDialog()
self.share_child_ui = Ui_Share_Dialog()
self.share_child_ui.setupUi(self.share_ui)

# 二维码分享配置窗口
self.qr_ui = QDialog()
self.qr_child_ui = Ui_Qr_Dialog()
self.qr_child_ui.setupUi(self.qr_ui)

self.current_page = self.first_widget
self.config_setting_widget.hide()
self.system_setting_widget.hide()
Expand Down Expand Up @@ -429,7 +435,7 @@ def setupUi(self, Form):
"background-color:transparent;")
self.lineEdit_2.setText("")
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_2.setPlaceholderText("以vmess://或ss://开头,回车确认")
self.lineEdit_2.setPlaceholderText("以vmess://或ss://开头,以英文;分隔多条,回车确认")
self.label_5 = QLabel(Form)
self.label_5.setGeometry(QRect(570, 90, 131, 21))
self.label_5.setStyleSheet("font: 13pt \"Purisa\";")
Expand Down Expand Up @@ -586,6 +592,7 @@ def retranslateUi(self, SystemSettings):
self.label_9.setText(_translate("SystemSettings", "1081"))
self.label_10.setText(_translate("SystemSettings", "1080"))


class Ui_HelpUi(object):
def setupUi(self, HelpUi):
HelpUi.setObjectName("HelpUi")
Expand Down Expand Up @@ -637,42 +644,40 @@ def setupUi(self, Form):
self.tableWidget = QTableWidget(Form)
self.tableWidget.setGeometry(QRect(0, 60, 770, 320))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(6)
self.tableWidget.setColumnCount(7)
# self.tableWidget.setRowCount(12)
self.label = QLabel(Form)
self.label.setGeometry(QRect(150, 30, 41, 21))
self.label.setGeometry(QRect(130, 30, 41, 21))
self.label.setStyleSheet('font: 75 14pt "宋体";font-weight:bold;')
self.label.setObjectName("label")
self.label_2 = QLabel(Form)
self.label_2.setGeometry(QRect(340, 30, 41, 21))
self.label_2.setGeometry(QRect(335, 30, 41, 21))
self.label_2.setStyleSheet('font: 75 14pt "宋体";font-weight:bold;')
self.label_2.setObjectName("label_2")
self.label_3 = QLabel(Form)
self.label_3.setGeometry(QRect(500, 30, 41, 21))
self.label_3.setGeometry(QRect(490, 30, 41, 21))
self.label_3.setStyleSheet('font: 75 14pt "宋体";font-weight:bold;')
self.label_3.setObjectName("label_3")
self.label_4 = QLabel(Form)
self.label_4.setGeometry(QRect(25, 30, 41, 21))
self.label_4.setGeometry(QRect(15, 30, 41, 21))
self.label_4.setStyleSheet('font: 75 14pt "宋体";font-weight:bold;')
self.label_4.setObjectName("label_4")
self.pushButton = QPushButton(Form)
self.pushButton.setGeometry(QRect(150, 400, 111, 31))
self.pushButton.setGeometry(QRect(200, 400, 111, 31))
self.pushButton.setStyleSheet(
"#pushButton{border-width: 0px; border-radius: 15px; background: #1E90FF; outline: none; font-family: Microsoft YaHei; color: white; font-size: 13px; }\n"
"#pushButton:hover{ background: #5599FF;}")
self.pushButton.setObjectName("pushButton")
self.pushButton_1 = QPushButton(Form)
self.pushButton_1.setGeometry(QRect(310, 400, 111, 31))
self.pushButton_1.setGeometry(QRect(360, 400, 130, 31))
self.pushButton_1.setStyleSheet(
"#pushButton_1{border-width: 0px; border-radius: 15px; background: #1E90FF; outline: none; font-family: Microsoft YaHei; color: white; font-size: 13px; }\n"
"#pushButton_1:hover{ background: #5599FF;}")
self.pushButton_1.setObjectName("pushButton_1")
self.pushButton_2 = QPushButton(Form)
self.pushButton_2.setGeometry(QRect(470, 400, 111, 31))
self.pushButton_2.setStyleSheet(
"#pushButton_2{border-width: 0px; border-radius: 15px; background: #1E90FF; outline: none; font-family: Microsoft YaHei; color: white; font-size: 13px; }\n"
"#pushButton_2:hover{ background: #5599FF;}")
self.pushButton_2.setObjectName("pushButton_2")
self.time = QLabel(Form)
self.time.setGeometry(QRect(510, 400, 100, 31))
self.time.setStyleSheet('font: 75 11pt "宋体";font-weight:bold;')
self.time.setObjectName("time")

self.tableWidget.setShowGrid(False)
self.tableWidget.setFrameShape(QFrame.NoFrame)
Expand All @@ -685,8 +690,9 @@ def setupUi(self, Form):
self.tableWidget.setColumnWidth(1, 200)
self.tableWidget.setColumnWidth(2, 200)
self.tableWidget.setColumnWidth(3, 100)
self.tableWidget.setColumnWidth(4, 100)
self.tableWidget.setColumnWidth(5, 100)
self.tableWidget.setColumnWidth(4, 80)
self.tableWidget.setColumnWidth(5, 50)
self.tableWidget.setColumnWidth(6, 50)
self.tableWidget.verticalHeader().setDefaultSectionSize(40)
self.tableWidget.setStyleSheet('''
#tableWidget{
Expand All @@ -707,24 +713,12 @@ def setupUi(self, Form):

def add_item(self, args):
item = QTableWidgetItem(str(args[0]))
# font = QFont()
# font.setPointSize(16)
# item.setFont(font)
self.tableWidget.setItem(args[0]-1, 0, item)
item = QTableWidgetItem(args[1])
# font = QFont()
# font.setPointSize(16)
# item.setFont(font)
self.tableWidget.setItem(args[0]-1, 1, item)
item = QTableWidgetItem(args[2])
# font = QFont()
# font.setPointSize(16)
# item.setFont(font)
self.tableWidget.setItem(args[0]-1, 2, item)
item = QTableWidgetItem(args[3])
# font = QFont()
# font.setPointSize(16)
# item.setFont(font)
self.tableWidget.setItem(args[0]-1, 3, item)
label_1 = QLabel()
if args[4]:
Expand All @@ -734,7 +728,7 @@ def add_item(self, args):
switchBtn.setGeometry(20, 5, 60, 30)
switchBtn.checkedChanged.connect(lambda: args[5](args[0]-1, not switchBtn.checked))
self.tableWidget.setCellWidget(args[0]-1, 4, label_1)
button1 = QPushButton("删除配置")
button1 = QPushButton("删除")
button1.setObjectName("delbt")
button1.setStyleSheet('''
#delbt{border-width: 0px;
Expand All @@ -750,6 +744,22 @@ def add_item(self, args):
''')
button1.clicked.connect(lambda: args[6](args[0]-1))
self.tableWidget.setCellWidget(args[0]-1, 5, button1)
button2 = QPushButton("分享")
button2.setObjectName("delbt")
button2.setStyleSheet('''
#delbt{border-width: 0px;
border-radius: 15px;
background: #1E90FF;
outline: none;
font-family: Microsoft YaHei;
color: white;
font-size: 13px;
margin:5px;
}
#delbt:hover{ background: #5599FF;}
''')
button2.clicked.connect(lambda: args[7](args[1]))
self.tableWidget.setCellWidget(args[0]-1, 6, button2)



Expand All @@ -761,8 +771,61 @@ def retranslateUi(self, Form):
self.label_3.setText(_translate("Form", "协议"))
self.label_4.setText(_translate("Form", "序号"))
self.pushButton.setText(_translate("Form", "更新订阅"))
self.pushButton_1.setText(_translate("Form", "生成分享URI"))
self.pushButton_2.setText(_translate("Form", "生成分享qrcode"))
self.pushButton_1.setText(_translate("Form", "测试当前延时"))


class Ui_Share_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(226, 171)
self.label = QLabel(Dialog)
self.label.setGeometry(QRect(20, 20, 191, 17))
self.label.setStyleSheet("font: 75 13pt \"新宋体\";")
self.label.setObjectName("label")
self.pushButton = QPushButton(Dialog)
self.pushButton.setGeometry(QRect(40, 60, 141, 31))
self.pushButton.setStyleSheet("#pushButton{border-width: 0px; border-radius: 15px; background: #1E90FF; outline: none; font-family: Microsoft YaHei; color: white; font-size: 13px; }\n"
"#pushButton:hover{ background: #5599FF;}")
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QPushButton(Dialog)
self.pushButton_2.setGeometry(QRect(40, 110, 141, 31))
self.pushButton_2.setStyleSheet("#pushButton_2{border-width: 0px; border-radius: 15px; background: #1E90FF; outline: none; font-family: Microsoft YaHei; color: white; font-size: 13px; }\n"
"#pushButton_2:hover{ background: #5599FF;}")
self.pushButton_2.setObjectName("pushButton_2")

self.retranslateUi(Dialog)
QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
_translate = QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "配置分享"))
self.label.setText(_translate("Dialog", "请选择以下一种方式分享"))
self.pushButton.setText(_translate("Dialog", "二维码分享"))
self.pushButton_2.setText(_translate("Dialog", "链接分享"))


class Ui_Qr_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(218, 218)
Dialog.setMinimumSize(QSize(218, 218))
Dialog.setMaximumSize(QSize(218, 218))
self.gridLayout = QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.label = QLabel(Dialog)
self.label.setEnabled(True)
self.label.setMinimumSize(QSize(200, 200))
self.label.setMaximumSize(QSize(200, 200))
self.label.setText("")
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)

self.retranslateUi(Dialog)
QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
_translate = QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "二维码分享配置"))

def main():
app = QApplication(sys.argv)
Expand Down
8 changes: 5 additions & 3 deletions v2rayL-GUI/sub2conf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import pickle
import requests
import urllib.parse as parse
from config import conf_template as conf


Expand Down Expand Up @@ -40,16 +41,16 @@ def __init__(self, subs_url=None, conf_url=None):

def b642conf(self, prot, tp, b64str):
if prot == "vmess":
ret = eval(base64.b64decode(b64str).decode())
ret = eval(parse.unquote(base64.b64decode(b64str).decode()))
region = ret['ps']

elif prot == "shadowsocks":
string = b64str.split("#")
cf = string[0].split("@")
if len(cf) == 1:
tmp = base64.b64decode(cf[0]).decode()
tmp = parse.unquote(base64.b64decode(cf[0]).decode())
else:
tmp = base64.b64decode(cf[0]).decode() + "@" + cf[1]
tmp = parse.unquote(base64.b64decode(cf[0]).decode()) + "@" + cf[1]
ret = {
"method": tmp.split(":")[0],
"port": tmp.split(":")[2],
Expand Down Expand Up @@ -208,6 +209,7 @@ def conf2b64(self, region):
if prot == "vmess":
return prot+"://"+base64.b64encode(str(tmp).encode()).decode()
else:
prot = "ss"
return prot+"://"+base64.b64encode("{}:{}@{}:{}".format(tmp["method"],
tmp["password"], tmp["add"],
tmp["port"]).encode()).decode()+"#"+region
Expand Down
12 changes: 8 additions & 4 deletions v2rayL-GUI/v2rayL_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import pickle
import re
import requests
from sub2conf_api import Sub2Conf, MyException


Expand Down Expand Up @@ -109,11 +110,14 @@ def addconf(self, uri):
def delconf(self, region):
self.subs.delconf(region)

def ping(self, addr):
def ping(self):
try:
p = subprocess.getoutput(["ping -c 1 "+addr])
res = re.search("time=(.*?)ms", p)
return res.group(1)
proxy = {
"http": "127.0.0.1:1081",
"https": "127.0.0.1:1081"
}
req = requests.get("http://www.google.com", proxies=proxy, timeout=10)
return req.elapsed.total_seconds()*1000
except:
raise MyException("测试超时")

Expand Down
12 changes: 6 additions & 6 deletions v2rayL-GUI/v2rayL_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,25 @@ class PingThread(QThread):
"""
sinOut = pyqtSignal(tuple)

def __init__(self, tv=(None, None), parent=None):
def __init__(self, v2ray=None, parent=None):
super(PingThread, self).__init__(parent)
self.tableView, self.v2rayL = tv
self.v2rayL = v2ray

def __del__(self):
# 线程状态改变与线程终止
self.wait()

def run(self):
try:
row = self.tableView.currentIndex().row()
addr = self.tableView.model().item(row, 1).text()
ret = self.v2rayL.ping(addr)
# # row = self.tableView.currentIndex().row()
# addr = self.tableView.model().item(self.row, 1).text()
ret = self.v2rayL.ping()
except MyException as e:
self.sinOut.emit(("ping", "@@Fail@@", e.args[0], None))
except AttributeError:
self.sinOut.emit(("ping", "@@Fail@@", "请选择需要测试的配置.", None))
else:
self.sinOut.emit(("ping", "@@OK@@", ret.strip(), None))
self.sinOut.emit(("ping", "@@OK@@", int(ret), None))


class CheckUpdateThread(QThread):
Expand Down
Loading

0 comments on commit 2345856

Please sign in to comment.