Skip to content

Commit

Permalink
Update UI to support SSR.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Incognito committed Dec 24, 2020
1 parent 0f97900 commit b8632b6
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ before_install:
# QByteArray::AbortOnBase64DecodingErrors is not supported until Qt 5.15
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sed -i "s/Qt::endl/endl/g" src/main.cpp;
sed -i "s/, QByteArray::AbortOnBase64DecodingErrors//g" src/serverconfighelper.cpp
sed -i "s/QByteArray::AbortOnBase64DecodingErrors/QByteArray::Base64Encoding/g" src/serverconfighelper.cpp;
fi

- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

## What's New in 2.0?

We use [Clash](https:/Dreamacro/clash) as the backend proxy, which supports **Shadowsocks**, **V2Ray**, and **Trojan** protocols.
We use [Clash](https:/Dreamacro/clash) as the backend proxy, which supports **Shadowsocks(R)**, **V2Ray**, and **Trojan** protocols.

## Introduction

V2Ray Desktop is a cross-platform GUI client that supports **Shadowsocks**, **V2Ray**, and **Trojan** protocols, running on Windows, Linux, and macOS.
V2Ray Desktop is a cross-platform GUI client that supports **Shadowsocks(R)**, **V2Ray**, and **Trojan** protocols, running on Windows, Linux, and macOS.
It is built with Qt 5 and QML 2.

Compared to [V2Ray](http://v2ray.com/), V2Ray Desktop provides more advanced features such as server subscription and latency test. You can easily migrate to V2Ray Desktop from [Shadowsocks-Qt5](https:/shadowsocks/shadowsocks-qt5/) and [V2Ray Core](http://v2ray.com/) by importing their config files.
Expand All @@ -21,20 +21,20 @@ If you are using Arch Linux, you can install from [archlinuxcn](https://github.c

**Notes:**
- Some functions (*e.g.,* server subscription) in the prebuilt binary packages require **OpenSSL >= 1.1.0**. If you are using Ubuntu<=18.04, please install OpenSSL manually. You can refer to [Installation Guide](https:/Dr-Incognito/V2Ray-Desktop/wiki/Installation) ([安装指南](https:/Dr-Incognito/V2Ray-Desktop/wiki/安装指南)) in the Wiki page for the detailed information.
- The AppImage for Linux is built in Ubuntu 16.04. Linux with GLIBC< 2.23 (*e.g.,* Ubuntu<=16.04) may have problems using this AppImage. Please consider building it from source with Qt >= 5.14.
- The AppImage for Linux is built in Ubuntu 16.04. Linux with GLIBC< 2.23 (*e.g.,* Ubuntu<=16.04) may have problems using this AppImage. Please consider building it from source with Qt >= 5.15.

For more information, please visit the [project's Wiki page](https:/Dr-Incognito/V2Ray-Desktop/wiki).

## Features

- Support Windows, Linux, and macOS.
- Support **Shadowsocks**, **V2Ray**, and **Trojan** servers.
- Support **Shadowsocks(R)**, **V2Ray**, and **Trojan** servers.
- Support connecting to multiple servers.
- Support adding/updating servers from subscription URLs.
- Support adding servers by importing [Shadowsocks-Qt5](https:/shadowsocks/shadowsocks-qt5/) and [V2Ray Core](http://v2ray.com/) configuration.
- Support adding servers by scanning QR codes.
- Support PAC proxy mode, Global proxy mode, and Manual proxy mode.
- Support getting and setting system proxies for Windows, Linux (GNOME), and macOS.
- Support getting and setting system proxies for Windows, Linux (GNOME/KDE), and macOS.
- Support automatically updating GFWList.
- Support automatically starts up when logged in.

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ install:
- git submodule update --init --recursive

build_script:
# Qt::endl and QByteArray::AbortOnBase64DecodingErrors are not supported until Qt 5.15
# Qt::endl and QByteArray::AbortOnBase64DecodingErrors are not supported until Qt 5.14 and 5.15, respectively.
- sed -i "s/Qt::endl/endl/g" src/main.cpp
- sed -i "s/, QByteArray::AbortOnBase64DecodingErrors//g" src/serverconfighelper.cpp
- sed -i "s/QByteArray::AbortOnBase64DecodingErrors/QByteArray::Base64Encoding/g" src/serverconfighelper.cpp
- qmake src\V2Ray-Desktop.pro
- mingw32-make -j4

Expand Down
14 changes: 7 additions & 7 deletions src/serverconfighelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ QJsonObject ServerConfigHelper::getPrettyShadowsocksConfig(

prettyServerCfg["obfs"] = plugins["obfs"].toString().toLower();
prettyServerCfg["protocol"] = plugins["protocol"].toString().toLower();
if (plugins.contains("obfs-host") &&
plugins["obfs-host"].toString().size()) {
prettyServerCfg["obfs-param"] = plugins["obfs-host"].toString();
if (plugins.contains("obfsparam") &&
plugins["obfsparam"].toString().size()) {
prettyServerCfg["obfs-param"] = plugins["obfsparam"].toString();
}
if (plugins.contains("protocol-param") &&
plugins["protocol-param"].toString().size()) {
if (plugins.contains("protoparam") &&
plugins["protoparam"].toString().size()) {
prettyServerCfg["protocol-param"] =
plugins["protocol-param"].toString().toLower();
plugins["protoparam"].toString().toLower();
}
if (plugins.contains("udp")) {
prettyServerCfg["udp"] = plugins["udp"].toBool();
Expand Down Expand Up @@ -401,7 +401,7 @@ QJsonObject ServerConfigHelper::getShadowsocksRServerConfigFromUrl(
QString server, const QString& subscriptionUrl) {
server = server.mid(6);
QString serverUrl = QByteArray::fromBase64(
server.toUtf8(), QByteArray::AbortOnBase64DecodingErrors);
server.toUtf8());
// Failed to parse the SSR URL
if (!serverUrl.size()) {
serverUrl = QByteArray::fromBase64(server.replace('_', '/').toUtf8(),
Expand Down
92 changes: 87 additions & 5 deletions src/ui/servers.qml
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,12 @@ ColumnLayout {
ListElement { text: "Disabled"; value: "" }
ListElement { text: "TLS"; value: "tls" }
ListElement { text: "HTTP"; value: "http" }
ListElement { text: "PLAIN"; value: "plain" }
ListElement { text: "HTTP SIMPLE"; value: "http_simple" }
ListElement { text: "HTTP POST"; value: "http_post" }
ListElement { text: "RANDOM HEAD"; value: "random_head" }
ListElement { text: "TLS1.2 TICKET AUTH"; value: "tls1.2_ticket_auth" }
ListElement { text: "TLS1.2 TICKET FASTAUTH"; value: "tls1.2_ticket_fastauth" }
}
background: Rectangle {
color: Qt.rgba(255, 255, 255, .1)
Expand All @@ -842,15 +848,75 @@ ColumnLayout {
leftPadding: 10
verticalAlignment: Text.AlignVCenter
}
onCurrentTextChanged: function() {
if (comboObfsMode.currentIndex < 3) {
// Shadowsocks
labelProtocol.visible = false
comboProtocol.visible = false
labelProtocolParameter.visible = false
textProtocolParameter.visible = false
} else {
// ShadowsocksR
labelProtocol.visible = true
comboProtocol.visible = true
labelProtocolParameter.visible = true
textProtocolParameter.visible = true
}
}
}

Label {
text: qsTr("Obfuscate Host")
text: qsTr("Obfuscate Parameter")
color: "white"
}

TextField {
id: textObfsHost
id: textObfsParameter
color: "white"
Layout.fillWidth: true
background: Rectangle {
color: Qt.rgba(255, 255, 255, .1)
border.color: Qt.rgba(120, 130, 140, .2)
}
}

Label {
id: labelProtocol
text: qsTr("Protocol")
color: "white"
}

ComboBox {
id: comboProtocol
Layout.fillWidth: true
model: ListModel{
ListElement { text: "Origin" }
ListElement { text: "AUTH_SHA1_V4" }
ListElement { text: "AUTH_AES128_MD5" }
ListElement { text: "AUTH_AES128_SHA1" }
ListElement { text: "AUTH_CHAIN_A" }
ListElement { text: "AUTH_CHAIN_B" }
}
background: Rectangle {
color: Qt.rgba(255, 255, 255, .1)
border.color: Qt.rgba(120, 130, 140, .2)
}
contentItem: Text {
text: comboProtocol.displayText
color: "white"
leftPadding: 10
verticalAlignment: Text.AlignVCenter
}
}

Label {
id: labelProtocolParameter
text: qsTr("Protocol Parameter")
color: "white"
}

TextField {
id: textProtocolParameter
color: "white"
Layout.fillWidth: true
background: Rectangle {
Expand Down Expand Up @@ -881,7 +947,16 @@ ColumnLayout {
"password": textShadowsocksPassword.text,
"plugins": {
"obfs": comboObfsMode.currentValue,
"obfs-host": textObfsHost.text
"obfs-host": textObfsParameter.text
}
}
if (comboObfsMode.currentIndex >= 3) {
// ShadowsocksR
server["plugins"] = {
"obfs": comboObfsMode.currentValue,
"obfsparam": textObfsParameter.text,
"protocol": comboProtocol.currentText,
"protoparam": textProtocolParameter.text
}
}
if (buttonShadowsocksAddServer.text === qsTr("Add Server")) {
Expand Down Expand Up @@ -1583,9 +1658,16 @@ ColumnLayout {
textShadowsocksPassword.text = server["password"]

if ("plugin-opts" in server) {
// Shadowsocks
comboObfsMode.currentIndex = comboObfsMode.indexOfValue(
server["plugin-opts"]["mode"] || "")
textObfsHost.text = server["plugin-opts"]["host"] || ""
textObfsParameter.text = server["plugin-opts"]["host"] || ""
} else if ("obfs" in server) {
// ShadowsocksR
comboObfsMode.currentIndex = comboObfsMode.indexOfValue(server["obfs"] || "")
textObfsParameter.text = "obfs-param" in server ? server["obfs-param"] : ""
comboProtocol.currentIndex = comboProtocol.indexOfValue(server["protocol"].toUpperCase() || "")
textProtocolParameter.text = "protocol-param" in server ? server["protocol-param"] : ""
}
} else if (protocol === "trojan") {
comboAddServerMethod.currentIndex = 2
Expand Down Expand Up @@ -1632,7 +1714,7 @@ ColumnLayout {
comboShadowsocksEncryptionMethod.currentIndex = 0
textShadowsocksPassword.text = ""
comboObfsMode.currentIndex = 0
textObfsHost.text = ""
textObfsParameter.text = ""
// Clear text fields for Trojan
textTrojanServerName.text = ""
checkboxTrojanAutoConnect.checked = false
Expand Down

0 comments on commit b8632b6

Please sign in to comment.