mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 60975c9596 |
@@ -16,7 +16,6 @@ jobs:
|
|||||||
QT_VERSION: 6.6.2
|
QT_VERSION: 6.6.2
|
||||||
QIF_VERSION: 4.7
|
QIF_VERSION: 4.7
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Install Qt'
|
- name: 'Install Qt'
|
||||||
@@ -83,7 +82,6 @@ jobs:
|
|||||||
QIF_VERSION: 4.7
|
QIF_VERSION: 4.7
|
||||||
BUILD_ARCH: 64
|
BUILD_ARCH: 64
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Get sources'
|
- name: 'Get sources'
|
||||||
@@ -146,7 +144,6 @@ jobs:
|
|||||||
CC: cc
|
CC: cc
|
||||||
CXX: c++
|
CXX: c++
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Setup xcode'
|
- name: 'Setup xcode'
|
||||||
@@ -238,7 +235,6 @@ jobs:
|
|||||||
QT_VERSION: 6.4.3
|
QT_VERSION: 6.4.3
|
||||||
QIF_VERSION: 4.6
|
QIF_VERSION: 4.6
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Setup xcode'
|
- name: 'Setup xcode'
|
||||||
@@ -304,7 +300,6 @@ jobs:
|
|||||||
QT_VERSION: 6.7.2
|
QT_VERSION: 6.7.2
|
||||||
QT_MODULES: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
|
QT_MODULES: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Install desktop Qt'
|
- name: 'Install desktop Qt'
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ jobs:
|
|||||||
QT_VERSION: 6.4.1
|
QT_VERSION: 6.4.1
|
||||||
QIF_VERSION: 4.5
|
QIF_VERSION: 4.5
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Install desktop Qt'
|
- name: 'Install desktop Qt'
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
|
|||||||
|
|
||||||
set(PROJECT AmneziaVPN)
|
set(PROJECT AmneziaVPN)
|
||||||
|
|
||||||
project(${PROJECT} VERSION 4.8.0.1
|
project(${PROJECT} VERSION 4.8.0.0
|
||||||
DESCRIPTION "AmneziaVPN"
|
DESCRIPTION "AmneziaVPN"
|
||||||
HOMEPAGE_URL "https://amnezia.org/"
|
HOMEPAGE_URL "https://amnezia.org/"
|
||||||
)
|
)
|
||||||
@@ -11,7 +11,7 @@ string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
|||||||
set(RELEASE_DATE "${CURRENT_DATE}")
|
set(RELEASE_DATE "${CURRENT_DATE}")
|
||||||
|
|
||||||
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
||||||
set(APP_ANDROID_VERSION_CODE 59)
|
set(APP_ANDROID_VERSION_CODE 58)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
set(MZ_PLATFORM_NAME "linux")
|
set(MZ_PLATFORM_NAME "linux")
|
||||||
|
|||||||
+1
-1
Submodule client/3rd-prebuilt updated: ba580dc5bd...c38a587fcd
@@ -1,28 +1,81 @@
|
|||||||
package org.amnezia.vpn.protocol.awg
|
package org.amnezia.vpn.protocol.awg
|
||||||
|
|
||||||
import org.amnezia.vpn.protocol.wireguard.Wireguard
|
import org.amnezia.vpn.protocol.wireguard.Wireguard
|
||||||
import org.amnezia.vpn.util.optStringOrNull
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config example:
|
||||||
|
* {
|
||||||
|
* "protocol": "awg",
|
||||||
|
* "description": "Server 1",
|
||||||
|
* "dns1": "1.1.1.1",
|
||||||
|
* "dns2": "1.0.0.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "splitTunnelSites": [
|
||||||
|
* ],
|
||||||
|
* "splitTunnelType": 0,
|
||||||
|
* "awg_config_data": {
|
||||||
|
* "H1": "969537490",
|
||||||
|
* "H2": "481688153",
|
||||||
|
* "H3": "2049399200",
|
||||||
|
* "H4": "52029755",
|
||||||
|
* "Jc": "3",
|
||||||
|
* "Jmax": "1000",
|
||||||
|
* "Jmin": "50",
|
||||||
|
* "S1": "49",
|
||||||
|
* "S2": "60",
|
||||||
|
* "client_ip": "10.8.1.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "port": 12345,
|
||||||
|
* "client_pub_key": "clientPublicKeyBase64",
|
||||||
|
* "client_priv_key": "privateKeyBase64",
|
||||||
|
* "psk_key": "presharedKeyBase64",
|
||||||
|
* "server_pub_key": "publicKeyBase64",
|
||||||
|
* "config": "[Interface]
|
||||||
|
* Address = 10.8.1.1/32
|
||||||
|
* DNS = 1.1.1.1, 1.0.0.1
|
||||||
|
* PrivateKey = privateKeyBase64
|
||||||
|
* Jc = 3
|
||||||
|
* Jmin = 50
|
||||||
|
* Jmax = 1000
|
||||||
|
* S1 = 49
|
||||||
|
* S2 = 60
|
||||||
|
* H1 = 969537490
|
||||||
|
* H2 = 481688153
|
||||||
|
* H3 = 2049399200
|
||||||
|
* H4 = 52029755
|
||||||
|
*
|
||||||
|
* [Peer]
|
||||||
|
* PublicKey = publicKeyBase64
|
||||||
|
* PresharedKey = presharedKeyBase64
|
||||||
|
* AllowedIPs = 0.0.0.0/0, ::/0
|
||||||
|
* Endpoint = 100.100.100.0:12345
|
||||||
|
* PersistentKeepalive = 25
|
||||||
|
* "
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
class Awg : Wireguard() {
|
class Awg : Wireguard() {
|
||||||
|
|
||||||
override val ifName: String = "awg0"
|
override val ifName: String = "awg0"
|
||||||
|
|
||||||
override fun parseConfig(config: JSONObject): AwgConfig {
|
override fun parseConfig(config: JSONObject): AwgConfig {
|
||||||
val configData = config.getJSONObject("awg_config_data")
|
val configDataJson = config.getJSONObject("awg_config_data")
|
||||||
|
val configData = parseConfigData(configDataJson.getString("config"))
|
||||||
return AwgConfig.build {
|
return AwgConfig.build {
|
||||||
configWireguard(config, configData)
|
configWireguard(configData, configDataJson)
|
||||||
configSplitTunneling(config)
|
configSplitTunneling(config)
|
||||||
configAppSplitTunneling(config)
|
configAppSplitTunneling(config)
|
||||||
configData.optStringOrNull("Jc")?.let { setJc(it.toInt()) }
|
configData["Jc"]?.let { setJc(it.toInt()) }
|
||||||
configData.optStringOrNull("Jmin")?.let { setJmin(it.toInt()) }
|
configData["Jmin"]?.let { setJmin(it.toInt()) }
|
||||||
configData.optStringOrNull("Jmax")?.let { setJmax(it.toInt()) }
|
configData["Jmax"]?.let { setJmax(it.toInt()) }
|
||||||
configData.optStringOrNull("S1")?.let { setS1(it.toInt()) }
|
configData["S1"]?.let { setS1(it.toInt()) }
|
||||||
configData.optStringOrNull("S2")?.let { setS2(it.toInt()) }
|
configData["S2"]?.let { setS2(it.toInt()) }
|
||||||
configData.optStringOrNull("H1")?.let { setH1(it.toLong()) }
|
configData["H1"]?.let { setH1(it.toLong()) }
|
||||||
configData.optStringOrNull("H2")?.let { setH2(it.toLong()) }
|
configData["H2"]?.let { setH2(it.toLong()) }
|
||||||
configData.optStringOrNull("H3")?.let { setH3(it.toLong()) }
|
configData["H3"]?.let { setH3(it.toLong()) }
|
||||||
configData.optStringOrNull("H4")?.let { setH4(it.toLong()) }
|
configData["H4"]?.let { setH4(it.toLong()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,36 @@ import net.openvpn.ovpn3.ClientAPI_Config
|
|||||||
import org.amnezia.vpn.protocol.openvpn.OpenVpn
|
import org.amnezia.vpn.protocol.openvpn.OpenVpn
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config Example:
|
||||||
|
* {
|
||||||
|
* "protocol": "cloak",
|
||||||
|
* "description": "Server 1",
|
||||||
|
* "dns1": "1.1.1.1",
|
||||||
|
* "dns2": "1.0.0.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "splitTunnelSites": [
|
||||||
|
* ],
|
||||||
|
* "splitTunnelType": 0,
|
||||||
|
* "openvpn_config_data": {
|
||||||
|
* "config": "openVpnConfig"
|
||||||
|
* }
|
||||||
|
* "cloak_config_data": {
|
||||||
|
* "BrowserSig": "chrome",
|
||||||
|
* "EncryptionMethod": "aes-gcm",
|
||||||
|
* "NumConn": 1,
|
||||||
|
* "ProxyMethod": "openvpn",
|
||||||
|
* "PublicKey": "PublicKey=",
|
||||||
|
* "RemoteHost": "100.100.100.0",
|
||||||
|
* "RemotePort": "443",
|
||||||
|
* "ServerName": "servername",
|
||||||
|
* "StreamTimeout": 300,
|
||||||
|
* "Transport": "direct",
|
||||||
|
* "UID": "UID="
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
class Cloak : OpenVpn() {
|
class Cloak : OpenVpn() {
|
||||||
|
|
||||||
override fun parseConfig(config: JSONObject): ClientAPI_Config {
|
override fun parseConfig(config: JSONObject): ClientAPI_Config {
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ import org.amnezia.vpn.util.net.getLocalNetworks
|
|||||||
import org.amnezia.vpn.util.net.parseInetAddress
|
import org.amnezia.vpn.util.net.parseInetAddress
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config Example:
|
||||||
|
* {
|
||||||
|
* "protocol": "openvpn",
|
||||||
|
* "description": "Server 1",
|
||||||
|
* "dns1": "1.1.1.1",
|
||||||
|
* "dns2": "1.0.0.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "splitTunnelSites": [
|
||||||
|
* ],
|
||||||
|
* "splitTunnelType": 0,
|
||||||
|
* "openvpn_config_data": {
|
||||||
|
* "config": "openVpnConfig"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
open class OpenVpn : Protocol() {
|
open class OpenVpn : Protocol() {
|
||||||
|
|
||||||
private var openVpnClient: OpenVpnClient? = null
|
private var openVpnClient: OpenVpnClient? = null
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package org.amnezia.vpn.util
|
|
||||||
|
|
||||||
import org.json.JSONArray
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
inline fun <reified T> JSONArray.asSequence(): Sequence<T> =
|
|
||||||
(0..<length()).asSequence().map { get(it) as T }
|
|
||||||
|
|
||||||
fun JSONObject.optStringOrNull(name: String) = optString(name).ifEmpty { null }
|
|
||||||
+68
-24
@@ -14,13 +14,46 @@ import org.amnezia.vpn.protocol.ProtocolState.DISCONNECTED
|
|||||||
import org.amnezia.vpn.protocol.Statistics
|
import org.amnezia.vpn.protocol.Statistics
|
||||||
import org.amnezia.vpn.protocol.VpnStartException
|
import org.amnezia.vpn.protocol.VpnStartException
|
||||||
import org.amnezia.vpn.util.Log
|
import org.amnezia.vpn.util.Log
|
||||||
import org.amnezia.vpn.util.asSequence
|
|
||||||
import org.amnezia.vpn.util.net.InetEndpoint
|
import org.amnezia.vpn.util.net.InetEndpoint
|
||||||
import org.amnezia.vpn.util.net.InetNetwork
|
import org.amnezia.vpn.util.net.InetNetwork
|
||||||
import org.amnezia.vpn.util.net.parseInetAddress
|
import org.amnezia.vpn.util.net.parseInetAddress
|
||||||
import org.amnezia.vpn.util.optStringOrNull
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config example:
|
||||||
|
* {
|
||||||
|
* "protocol": "wireguard",
|
||||||
|
* "description": "Server 1",
|
||||||
|
* "dns1": "1.1.1.1",
|
||||||
|
* "dns2": "1.0.0.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "splitTunnelSites": [
|
||||||
|
* ],
|
||||||
|
* "splitTunnelType": 0,
|
||||||
|
* "wireguard_config_data": {
|
||||||
|
* "client_ip": "10.8.1.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "port": 12345,
|
||||||
|
* "client_pub_key": "clientPublicKeyBase64",
|
||||||
|
* "client_priv_key": "privateKeyBase64",
|
||||||
|
* "psk_key": "presharedKeyBase64",
|
||||||
|
* "server_pub_key": "publicKeyBase64",
|
||||||
|
* "config": "[Interface]
|
||||||
|
* Address = 10.8.1.1/32
|
||||||
|
* DNS = 1.1.1.1, 1.0.0.1
|
||||||
|
* PrivateKey = privateKeyBase64
|
||||||
|
*
|
||||||
|
* [Peer]
|
||||||
|
* PublicKey = publicKeyBase64
|
||||||
|
* PresharedKey = presharedKeyBase64
|
||||||
|
* AllowedIPs = 0.0.0.0/0, ::/0
|
||||||
|
* Endpoint = 100.100.100.0:12345
|
||||||
|
* PersistentKeepalive = 25
|
||||||
|
* "
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
private const val TAG = "Wireguard"
|
private const val TAG = "Wireguard"
|
||||||
|
|
||||||
open class Wireguard : Protocol() {
|
open class Wireguard : Protocol() {
|
||||||
@@ -90,49 +123,60 @@ open class Wireguard : Protocol() {
|
|||||||
.inputStream.reader().readText()
|
.inputStream.reader().readText()
|
||||||
|
|
||||||
protected open fun parseConfig(config: JSONObject): WireguardConfig {
|
protected open fun parseConfig(config: JSONObject): WireguardConfig {
|
||||||
val configData = config.getJSONObject("wireguard_config_data")
|
val configDataJson = config.getJSONObject("wireguard_config_data")
|
||||||
|
val configData = parseConfigData(configDataJson.getString("config"))
|
||||||
return WireguardConfig.build {
|
return WireguardConfig.build {
|
||||||
configWireguard(config, configData)
|
configWireguard(configData, configDataJson)
|
||||||
configSplitTunneling(config)
|
configSplitTunneling(config)
|
||||||
configAppSplitTunneling(config)
|
configAppSplitTunneling(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun WireguardConfig.Builder.configWireguard(config: JSONObject, configData: JSONObject) {
|
protected fun WireguardConfig.Builder.configWireguard(configData: Map<String, String>, configDataJson: JSONObject) {
|
||||||
configData.getString("client_ip").split(",").map { address ->
|
configData["Address"]?.split(",")?.map { address ->
|
||||||
InetNetwork.parse(address.trim())
|
InetNetwork.parse(address.trim())
|
||||||
}.forEach(::addAddress)
|
}?.forEach(::addAddress)
|
||||||
|
|
||||||
config.optStringOrNull("dns1")?.let { dns ->
|
configData["DNS"]?.split(",")?.map { dns ->
|
||||||
addDnsServer(parseInetAddress(dns.trim()))
|
parseInetAddress(dns.trim())
|
||||||
}
|
}?.forEach(::addDnsServer)
|
||||||
|
|
||||||
config.optStringOrNull("dns2")?.let { dns ->
|
|
||||||
addDnsServer(parseInetAddress(dns.trim()))
|
|
||||||
}
|
|
||||||
|
|
||||||
val defRoutes = hashSetOf(
|
val defRoutes = hashSetOf(
|
||||||
InetNetwork("0.0.0.0", 0),
|
InetNetwork("0.0.0.0", 0),
|
||||||
InetNetwork("::", 0)
|
InetNetwork("::", 0)
|
||||||
)
|
)
|
||||||
val routes = hashSetOf<InetNetwork>()
|
val routes = hashSetOf<InetNetwork>()
|
||||||
configData.getJSONArray("allowed_ips").asSequence<String>().map { route ->
|
configData["AllowedIPs"]?.split(",")?.map { route ->
|
||||||
InetNetwork.parse(route.trim())
|
InetNetwork.parse(route.trim())
|
||||||
}.forEach(routes::add)
|
}?.forEach(routes::add)
|
||||||
// if the allowed IPs list contains at least one non-default route, disable global split tunneling
|
// if the allowed IPs list contains at least one non-default route, disable global split tunneling
|
||||||
if (routes.any { it !in defRoutes }) disableSplitTunneling()
|
if (routes.any { it !in defRoutes }) disableSplitTunneling()
|
||||||
addRoutes(routes)
|
addRoutes(routes)
|
||||||
|
|
||||||
configData.optStringOrNull("mtu")?.let { setMtu(it.toInt()) }
|
configDataJson.optString("mtu").let { mtu ->
|
||||||
|
if (mtu.isNotEmpty()) {
|
||||||
|
setMtu(mtu.toInt())
|
||||||
|
} else {
|
||||||
|
configData["MTU"]?.let { setMtu(it.toInt()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val host = configData.getString("hostName").let { parseInetAddress(it.trim()) }
|
configData["Endpoint"]?.let { setEndpoint(InetEndpoint.parse(it)) }
|
||||||
val port = configData.getInt("port")
|
configData["PersistentKeepalive"]?.let { setPersistentKeepalive(it.toInt()) }
|
||||||
setEndpoint(InetEndpoint(host, port))
|
configData["PrivateKey"]?.let { setPrivateKeyHex(it.base64ToHex()) }
|
||||||
|
configData["PublicKey"]?.let { setPublicKeyHex(it.base64ToHex()) }
|
||||||
|
configData["PresharedKey"]?.let { setPreSharedKeyHex(it.base64ToHex()) }
|
||||||
|
}
|
||||||
|
|
||||||
configData.optStringOrNull("persistent_keep_alive")?.let { setPersistentKeepalive(it.toInt()) }
|
protected fun parseConfigData(data: String): Map<String, String> {
|
||||||
configData.getString("client_priv_key").let { setPrivateKeyHex(it.base64ToHex()) }
|
val parsedData = TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER)
|
||||||
configData.getString("server_pub_key").let { setPublicKeyHex(it.base64ToHex()) }
|
data.lineSequence()
|
||||||
configData.optStringOrNull("psk_key")?.let { setPreSharedKeyHex(it.base64ToHex()) }
|
.filter { it.isNotEmpty() && !it.startsWith('[') }
|
||||||
|
.forEach { line ->
|
||||||
|
val attr = line.split("=", limit = 2)
|
||||||
|
parsedData[attr.first().trim()] = attr.last().trim()
|
||||||
|
}
|
||||||
|
return parsedData
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun start(config: WireguardConfig, vpnBuilder: Builder, protect: (Int) -> Boolean) {
|
private fun start(config: WireguardConfig, vpnBuilder: Builder, protect: (Int) -> Boolean) {
|
||||||
|
|||||||
@@ -20,6 +20,69 @@ import org.amnezia.vpn.util.net.InetNetwork
|
|||||||
import org.amnezia.vpn.util.net.parseInetAddress
|
import org.amnezia.vpn.util.net.parseInetAddress
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config example:
|
||||||
|
* {
|
||||||
|
* "appSplitTunnelType": 0,
|
||||||
|
* "config_version": 0,
|
||||||
|
* "description": "Server 1",
|
||||||
|
* "dns1": "1.1.1.1",
|
||||||
|
* "dns2": "1.0.0.1",
|
||||||
|
* "hostName": "100.100.100.0",
|
||||||
|
* "protocol": "xray",
|
||||||
|
* "splitTunnelApps": [],
|
||||||
|
* "splitTunnelSites": [],
|
||||||
|
* "splitTunnelType": 0,
|
||||||
|
* "xray_config_data": {
|
||||||
|
* "inbounds": [
|
||||||
|
* {
|
||||||
|
* "listen": "127.0.0.1",
|
||||||
|
* "port": 8080,
|
||||||
|
* "protocol": "socks",
|
||||||
|
* "settings": {
|
||||||
|
* "udp": true
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ],
|
||||||
|
* "log": {
|
||||||
|
* "loglevel": "error"
|
||||||
|
* },
|
||||||
|
* "outbounds": [
|
||||||
|
* {
|
||||||
|
* "protocol": "vless",
|
||||||
|
* "settings": {
|
||||||
|
* "vnext": [
|
||||||
|
* {
|
||||||
|
* "address": "100.100.100.0",
|
||||||
|
* "port": 443,
|
||||||
|
* "users": [
|
||||||
|
* {
|
||||||
|
* "encryption": "none",
|
||||||
|
* "flow": "xtls-rprx-vision",
|
||||||
|
* "id": "id"
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* },
|
||||||
|
* "streamSettings": {
|
||||||
|
* "network": "tcp",
|
||||||
|
* "realitySettings": {
|
||||||
|
* "fingerprint": "chrome",
|
||||||
|
* "publicKey": "publicKey",
|
||||||
|
* "serverName": "google.com",
|
||||||
|
* "shortId": "id",
|
||||||
|
* "spiderX": ""
|
||||||
|
* },
|
||||||
|
* "security": "reality"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
private const val TAG = "Xray"
|
private const val TAG = "Xray"
|
||||||
private const val LIBXRAY_TAG = "libXray"
|
private const val LIBXRAY_TAG = "libXray"
|
||||||
|
|
||||||
|
|||||||
@@ -187,10 +187,6 @@ QString WireguardConfigurator::createConfig(const ServerCredentials &credentials
|
|||||||
jConfig[config_key::server_pub_key] = connData.serverPubKey;
|
jConfig[config_key::server_pub_key] = connData.serverPubKey;
|
||||||
jConfig[config_key::mtu] = wireguarConfig.value(config_key::mtu).toString(protocols::wireguard::defaultMtu);
|
jConfig[config_key::mtu] = wireguarConfig.value(config_key::mtu).toString(protocols::wireguard::defaultMtu);
|
||||||
|
|
||||||
jConfig[config_key::persistent_keep_alive] = 25;
|
|
||||||
QJsonArray allowedIps { "0.0.0.0/0", "::/0" };
|
|
||||||
jConfig[config_key::allowed_ips] = allowedIps;
|
|
||||||
|
|
||||||
jConfig[config_key::clientId] = connData.clientPubKey;
|
jConfig[config_key::clientId] = connData.clientPubKey;
|
||||||
|
|
||||||
return QJsonDocument(jConfig).toJson();
|
return QJsonDocument(jConfig).toJson();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "configurators/wireguard_configurator.h"
|
#include "configurators/wireguard_configurator.h"
|
||||||
#include "core/enums/apiEnums.h"
|
#include "core/enums/apiEnums.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "utilities.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -362,6 +363,7 @@ ErrorCode ApiController::getConfigForService(const QString &installationUuid, co
|
|||||||
publicKey = rsa.getPublicKeyFromByteArray(key);
|
publicKey = rsa.getPublicKeyFromByteArray(key);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
qCritical() << "error loading public key from environment variables";
|
qCritical() << "error loading public key from environment variables";
|
||||||
|
Utils::logException();
|
||||||
return ErrorCode::ApiMissingAgwPublicKey;
|
return ErrorCode::ApiMissingAgwPublicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ private:
|
|||||||
|
|
||||||
QString m_gatewayEndpoint;
|
QString m_gatewayEndpoint;
|
||||||
QStringList m_proxyUrls;
|
QStringList m_proxyUrls;
|
||||||
bool m_isDevEnvironment = false;
|
bool m_isDevEnvironment;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APICONTROLLER_H
|
#endif // APICONTROLLER_H
|
||||||
|
|||||||
@@ -101,14 +101,6 @@ QJsonObject VpnConfigurationsController::createVpnConfiguration(const QPair<QStr
|
|||||||
|
|
||||||
QJsonObject vpnConfigData = QJsonDocument::fromJson(protocolConfigString.toUtf8()).object();
|
QJsonObject vpnConfigData = QJsonDocument::fromJson(protocolConfigString.toUtf8()).object();
|
||||||
vpnConfigData = QJsonDocument::fromJson(protocolConfigString.toUtf8()).object();
|
vpnConfigData = QJsonDocument::fromJson(protocolConfigString.toUtf8()).object();
|
||||||
|
|
||||||
// add mtu for old configs
|
|
||||||
if (container == DockerContainer::Awg || container == DockerContainer::WireGuard) {
|
|
||||||
if (vpnConfigData[config_key::mtu].toString().isEmpty()) {
|
|
||||||
vpnConfigData[config_key::mtu] = container == DockerContainer::Awg ? protocols::awg::defaultMtu : protocols::wireguard::defaultMtu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnConfiguration.insert(ProtocolProps::key_proto_config_data(proto), vpnConfigData);
|
vpnConfiguration.insert(ProtocolProps::key_proto_config_data(proto), vpnConfigData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ void LocalSocketController::activate(const QJsonObject &rawConfig) {
|
|||||||
QJsonArray jsAllowedIPAddesses;
|
QJsonArray jsAllowedIPAddesses;
|
||||||
|
|
||||||
QJsonArray plainAllowedIP = wgConfig.value(amnezia::config_key::allowed_ips).toArray();
|
QJsonArray plainAllowedIP = wgConfig.value(amnezia::config_key::allowed_ips).toArray();
|
||||||
QJsonArray defaultAllowedIP = { "0.0.0.0/0", "::/0" };
|
QJsonArray defaultAllowedIP = QJsonArray::fromStringList(QString("0.0.0.0/0, ::/0").split(","));
|
||||||
|
|
||||||
if (plainAllowedIP != defaultAllowedIP && !plainAllowedIP.isEmpty()) {
|
if (plainAllowedIP != defaultAllowedIP && !plainAllowedIP.isEmpty()) {
|
||||||
// Use AllowedIP list from WG config because of higher priority
|
// Use AllowedIP list from WG config because of higher priority
|
||||||
|
|||||||
@@ -351,6 +351,8 @@ void IosController::vpnStatusDidChange(void *pNotification)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Disconnect error is absent";
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
} else {
|
} else {
|
||||||
@@ -833,7 +835,7 @@ QString IosController::openFile() {
|
|||||||
|
|
||||||
void IosController::requestInetAccess() {
|
void IosController::requestInetAccess() {
|
||||||
NSURL *url = [NSURL URLWithString:@"http://captive.apple.com/generate_204"];
|
NSURL *url = [NSURL URLWithString:@"http://captive.apple.com/generate_204"];
|
||||||
if (!url) {
|
if (url) {
|
||||||
qDebug() << "IosController::requestInetAccess URL error";
|
qDebug() << "IosController::requestInetAccess URL error";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -845,6 +847,7 @@ void IosController::requestInetAccess() {
|
|||||||
} else {
|
} else {
|
||||||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
|
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
|
||||||
QString responseBody = QString::fromUtf8((const char*)data.bytes, data.length);
|
QString responseBody = QString::fromUtf8((const char*)data.bytes, data.length);
|
||||||
|
qDebug() << "IosController::requestInetAccess server response:" << httpResponse.statusCode << "\n\n" <<responseBody;
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
[task resume];
|
[task resume];
|
||||||
|
|||||||
@@ -264,12 +264,12 @@ void LinuxFirewall::install()
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// installAnchor(IPv4, QStringLiteral("290.allowDHCP"), {
|
installAnchor(IPv4, QStringLiteral("290.allowDHCP"), {
|
||||||
// QStringLiteral("-p udp -d 255.255.255.255 --sport 68 --dport 67 -j ACCEPT"),
|
QStringLiteral("-p udp -d 255.255.255.255 --sport 68 --dport 67 -j ACCEPT"),
|
||||||
// });
|
});
|
||||||
// installAnchor(IPv6, QStringLiteral("290.allowDHCP"), {
|
installAnchor(IPv6, QStringLiteral("290.allowDHCP"), {
|
||||||
// QStringLiteral("-p udp -d ff00::/8 --sport 546 --dport 547 -j ACCEPT"),
|
QStringLiteral("-p udp -d ff00::/8 --sport 546 --dport 547 -j ACCEPT"),
|
||||||
// });
|
});
|
||||||
installAnchor(IPv6, QStringLiteral("250.blockIPv6"), {
|
installAnchor(IPv6, QStringLiteral("250.blockIPv6"), {
|
||||||
QStringLiteral("! -o lo+ -j REJECT"),
|
QStringLiteral("! -o lo+ -j REJECT"),
|
||||||
});
|
});
|
||||||
@@ -351,7 +351,7 @@ void LinuxFirewall::uninstall()
|
|||||||
uninstallAnchor(IPv4, QStringLiteral("320.allowDNS"));
|
uninstallAnchor(IPv4, QStringLiteral("320.allowDNS"));
|
||||||
uninstallAnchor(Both, QStringLiteral("310.blockDNS"));
|
uninstallAnchor(Both, QStringLiteral("310.blockDNS"));
|
||||||
uninstallAnchor(Both, QStringLiteral("300.allowLAN"));
|
uninstallAnchor(Both, QStringLiteral("300.allowLAN"));
|
||||||
// uninstallAnchor(Both, QStringLiteral("290.allowDHCP"));
|
uninstallAnchor(Both, QStringLiteral("290.allowDHCP"));
|
||||||
uninstallAnchor(IPv6, QStringLiteral("250.blockIPv6"));
|
uninstallAnchor(IPv6, QStringLiteral("250.blockIPv6"));
|
||||||
uninstallAnchor(Both, QStringLiteral("200.allowVPN"));
|
uninstallAnchor(Both, QStringLiteral("200.allowVPN"));
|
||||||
uninstallAnchor(IPv4, QStringLiteral("120.blockNets"));
|
uninstallAnchor(IPv4, QStringLiteral("120.blockNets"));
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void WireguardUtilsLinux::applyFirewallRules(FirewallParams& params)
|
|||||||
LinuxFirewall::updateBlockNets(params.blockAddrs);
|
LinuxFirewall::updateBlockNets(params.blockAddrs);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("200.allowVPN"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("200.allowVPN"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv6, QStringLiteral("250.blockIPv6"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv6, QStringLiteral("250.blockIPv6"), true);
|
||||||
// LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("290.allowDHCP"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("290.allowDHCP"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("300.allowLAN"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("300.allowLAN"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("310.blockDNS"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("310.blockDNS"), true);
|
||||||
LinuxFirewall::updateDNSServers(params.dnsServers);
|
LinuxFirewall::updateDNSServers(params.dnsServers);
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ void WireguardUtilsMacos::applyFirewallRules(FirewallParams& params)
|
|||||||
|
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("200.allowVPN"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("200.allowVPN"), true);
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("250.blockIPv6"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("250.blockIPv6"), true);
|
||||||
// MacOSFirewall::setAnchorEnabled(QStringLiteral("290.allowDHCP"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("290.allowDHCP"), true);
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("300.allowLAN"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("300.allowLAN"), true);
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("310.blockDNS"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("310.blockDNS"), true);
|
||||||
MacOSFirewall::setAnchorTable(QStringLiteral("310.blockDNS"), true, QStringLiteral("dnsaddr"), params.dnsServers);
|
MacOSFirewall::setAnchorTable(QStringLiteral("310.blockDNS"), true, QStringLiteral("dnsaddr"), params.dnsServers);
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ bool WindowsFirewall::enableKillSwitch(int vpnAdapterIndex) {
|
|||||||
logger.info() << "Enabling Killswitch Using Adapter:" << vpnAdapterIndex;
|
logger.info() << "Enabling Killswitch Using Adapter:" << vpnAdapterIndex;
|
||||||
FW_OK(allowTrafficOfAdapter(vpnAdapterIndex, MED_WEIGHT,
|
FW_OK(allowTrafficOfAdapter(vpnAdapterIndex, MED_WEIGHT,
|
||||||
"Allow usage of VPN Adapter"));
|
"Allow usage of VPN Adapter"));
|
||||||
// FW_OK(allowDHCPTraffic(MED_WEIGHT, "Allow DHCP Traffic"));
|
FW_OK(allowDHCPTraffic(MED_WEIGHT, "Allow DHCP Traffic"));
|
||||||
FW_OK(allowHyperVTraffic(MED_WEIGHT, "Allow Hyper-V Traffic"));
|
FW_OK(allowHyperVTraffic(MED_WEIGHT, "Allow Hyper-V Traffic"));
|
||||||
FW_OK(allowTrafficForAppOnAll(getCurrentPath(), MAX_WEIGHT,
|
FW_OK(allowTrafficForAppOnAll(getCurrentPath(), MAX_WEIGHT,
|
||||||
"Allow all for AmneziaVPN.exe"));
|
"Allow all for AmneziaVPN.exe"));
|
||||||
|
|||||||
@@ -199,8 +199,6 @@
|
|||||||
<file>server_scripts/socks5_proxy/Dockerfile</file>
|
<file>server_scripts/socks5_proxy/Dockerfile</file>
|
||||||
<file>server_scripts/socks5_proxy/configure_container.sh</file>
|
<file>server_scripts/socks5_proxy/configure_container.sh</file>
|
||||||
<file>server_scripts/socks5_proxy/start.sh</file>
|
<file>server_scripts/socks5_proxy/start.sh</file>
|
||||||
<file>ui/qml/Pages2/PageProtocolAwgClientSettings.qml</file>
|
|
||||||
<file>ui/qml/Pages2/PageProtocolWireGuardClientSettings.qml</file>
|
|
||||||
<file>ui/qml/Pages2/PageSetupWizardApiServicesList.qml</file>
|
<file>ui/qml/Pages2/PageSetupWizardApiServicesList.qml</file>
|
||||||
<file>ui/qml/Pages2/PageSetupWizardApiServiceInfo.qml</file>
|
<file>ui/qml/Pages2/PageSetupWizardApiServiceInfo.qml</file>
|
||||||
<file>ui/qml/Controls2/CardWithIconsType.qml</file>
|
<file>ui/qml/Controls2/CardWithIconsType.qml</file>
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ bool ImportController::extractConfigFromData(QString data)
|
|||||||
}
|
}
|
||||||
case ConfigTypes::Amnezia: {
|
case ConfigTypes::Amnezia: {
|
||||||
m_config = QJsonDocument::fromJson(config.toUtf8()).object();
|
m_config = QJsonDocument::fromJson(config.toUtf8()).object();
|
||||||
processAmneziaConfig(m_config);
|
|
||||||
if (!m_config.empty()) {
|
if (!m_config.empty()) {
|
||||||
checkForMaliciousStrings(m_config);
|
checkForMaliciousStrings(m_config);
|
||||||
return true;
|
return true;
|
||||||
@@ -396,11 +395,7 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
|||||||
lastConfig[config_key::mtu] = configMap.value("MTU");
|
lastConfig[config_key::mtu] = configMap.value("MTU");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configMap.value("PersistentKeepalive").isEmpty()) {
|
QJsonArray allowedIpsJsonArray = QJsonArray::fromStringList(configMap.value("AllowedIPs").split(","));
|
||||||
lastConfig[config_key::persistent_keep_alive] = configMap.value("PersistentKeepalive");
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonArray allowedIpsJsonArray = QJsonArray::fromStringList(configMap.value("AllowedIPs").split(", "));
|
|
||||||
|
|
||||||
lastConfig[config_key::allowed_ips] = allowedIpsJsonArray;
|
lastConfig[config_key::allowed_ips] = allowedIpsJsonArray;
|
||||||
|
|
||||||
@@ -424,12 +419,6 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
|||||||
m_configType = ConfigTypes::Awg;
|
m_configType = ConfigTypes::Awg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configMap.value("MTU").isEmpty()) {
|
|
||||||
lastConfig[config_key::mtu] = configMap.value("MTU");
|
|
||||||
} else {
|
|
||||||
lastConfig[config_key::mtu] = protocolName == "awg" ? protocols::awg::defaultMtu : protocols::wireguard::defaultMtu;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject wireguardConfig;
|
QJsonObject wireguardConfig;
|
||||||
wireguardConfig[config_key::last_config] = QString(QJsonDocument(lastConfig).toJson());
|
wireguardConfig[config_key::last_config] = QString(QJsonDocument(lastConfig).toJson());
|
||||||
wireguardConfig[config_key::isThirdPartyConfig] = true;
|
wireguardConfig[config_key::isThirdPartyConfig] = true;
|
||||||
@@ -657,28 +646,3 @@ void ImportController::checkForMaliciousStrings(const QJsonObject &serverConfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportController::processAmneziaConfig(QJsonObject &config)
|
|
||||||
{
|
|
||||||
auto containers = config.value(config_key::containers).toArray();
|
|
||||||
for (auto i = 0; i < containers.size(); i++) {
|
|
||||||
auto container = containers.at(i).toObject();
|
|
||||||
auto dockerContainer = ContainerProps::containerFromString(container.value(config_key::container).toString());
|
|
||||||
if (dockerContainer == DockerContainer::Awg || dockerContainer == DockerContainer::WireGuard) {
|
|
||||||
auto containerConfig = container.value(ContainerProps::containerTypeToString(dockerContainer)).toObject();
|
|
||||||
auto protocolConfig = containerConfig.value(config_key::last_config).toString();
|
|
||||||
if (protocolConfig.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject jsonConfig = QJsonDocument::fromJson(protocolConfig.toUtf8()).object();
|
|
||||||
jsonConfig[config_key::mtu] = dockerContainer == DockerContainer::Awg ? protocols::awg::defaultMtu : protocols::wireguard::defaultMtu;
|
|
||||||
|
|
||||||
containerConfig[config_key::last_config] = QString(QJsonDocument(jsonConfig).toJson());
|
|
||||||
|
|
||||||
container[ContainerProps::containerTypeToString(dockerContainer)] = containerConfig;
|
|
||||||
containers.replace(i, container);
|
|
||||||
config.insert(config_key::containers, containers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ private:
|
|||||||
|
|
||||||
void checkForMaliciousStrings(const QJsonObject &protocolConfig);
|
void checkForMaliciousStrings(const QJsonObject &protocolConfig);
|
||||||
|
|
||||||
void processAmneziaConfig(QJsonObject &config);
|
|
||||||
|
|
||||||
#if defined Q_OS_ANDROID || defined Q_OS_IOS
|
#if defined Q_OS_ANDROID || defined Q_OS_IOS
|
||||||
void stopDecodingQr();
|
void stopDecodingQr();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ void PageController::showOnStartup()
|
|||||||
if (!m_settings->isStartMinimized()) {
|
if (!m_settings->isStartMinimized()) {
|
||||||
emit raiseMainWindow();
|
emit raiseMainWindow();
|
||||||
} else {
|
} else {
|
||||||
#if defined(Q_OS_WIN) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
|
||||||
emit hideMainWindow();
|
emit hideMainWindow();
|
||||||
#elif defined Q_OS_MACX
|
#elif defined Q_OS_MACX
|
||||||
setDockIconVisible(false);
|
setDockIconVisible(false);
|
||||||
|
|||||||
@@ -59,9 +59,6 @@ namespace PageLoader
|
|||||||
PageProtocolIKev2Settings,
|
PageProtocolIKev2Settings,
|
||||||
PageProtocolRaw,
|
PageProtocolRaw,
|
||||||
|
|
||||||
PageProtocolWireGuardClientSettings,
|
|
||||||
PageProtocolAwgClientSettings,
|
|
||||||
|
|
||||||
PageShareFullAccess,
|
PageShareFullAccess,
|
||||||
|
|
||||||
PageDevMenu
|
PageDevMenu
|
||||||
|
|||||||
@@ -21,30 +21,17 @@ bool AwgConfigModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::PortRole: m_serverProtocolConfig.insert(config_key::port, value.toString()); break;
|
case Roles::PortRole: m_protocolConfig.insert(config_key::port, value.toString()); break;
|
||||||
|
case Roles::MtuRole: m_protocolConfig.insert(config_key::mtu, value.toString()); break;
|
||||||
case Roles::ClientMtuRole: m_clientProtocolConfig.insert(config_key::mtu, value.toString()); break;
|
case Roles::JunkPacketCountRole: m_protocolConfig.insert(config_key::junkPacketCount, value.toString()); break;
|
||||||
case Roles::ClientJunkPacketCountRole: m_clientProtocolConfig.insert(config_key::junkPacketCount, value.toString()); break;
|
case Roles::JunkPacketMinSizeRole: m_protocolConfig.insert(config_key::junkPacketMinSize, value.toString()); break;
|
||||||
case Roles::ClientJunkPacketMinSizeRole: m_clientProtocolConfig.insert(config_key::junkPacketMinSize, value.toString()); break;
|
case Roles::JunkPacketMaxSizeRole: m_protocolConfig.insert(config_key::junkPacketMaxSize, value.toString()); break;
|
||||||
case Roles::ClientJunkPacketMaxSizeRole: m_clientProtocolConfig.insert(config_key::junkPacketMaxSize, value.toString()); break;
|
case Roles::InitPacketJunkSizeRole: m_protocolConfig.insert(config_key::initPacketJunkSize, value.toString()); break;
|
||||||
|
case Roles::ResponsePacketJunkSizeRole: m_protocolConfig.insert(config_key::responsePacketJunkSize, value.toString()); break;
|
||||||
case Roles::ServerJunkPacketCountRole: m_serverProtocolConfig.insert(config_key::junkPacketCount, value.toString()); break;
|
case Roles::InitPacketMagicHeaderRole: m_protocolConfig.insert(config_key::initPacketMagicHeader, value.toString()); break;
|
||||||
case Roles::ServerJunkPacketMinSizeRole: m_serverProtocolConfig.insert(config_key::junkPacketMinSize, value.toString()); break;
|
case Roles::ResponsePacketMagicHeaderRole: m_protocolConfig.insert(config_key::responsePacketMagicHeader, value.toString()); break;
|
||||||
case Roles::ServerJunkPacketMaxSizeRole: m_serverProtocolConfig.insert(config_key::junkPacketMaxSize, value.toString()); break;
|
case Roles::UnderloadPacketMagicHeaderRole: m_protocolConfig.insert(config_key::underloadPacketMagicHeader, value.toString()); break;
|
||||||
case Roles::ServerInitPacketJunkSizeRole: m_serverProtocolConfig.insert(config_key::initPacketJunkSize, value.toString()); break;
|
case Roles::TransportPacketMagicHeaderRole: m_protocolConfig.insert(config_key::transportPacketMagicHeader, value.toString()); break;
|
||||||
case Roles::ServerResponsePacketJunkSizeRole:
|
|
||||||
m_serverProtocolConfig.insert(config_key::responsePacketJunkSize, value.toString());
|
|
||||||
break;
|
|
||||||
case Roles::ServerInitPacketMagicHeaderRole: m_serverProtocolConfig.insert(config_key::initPacketMagicHeader, value.toString()); break;
|
|
||||||
case Roles::ServerResponsePacketMagicHeaderRole:
|
|
||||||
m_serverProtocolConfig.insert(config_key::responsePacketMagicHeader, value.toString());
|
|
||||||
break;
|
|
||||||
case Roles::ServerUnderloadPacketMagicHeaderRole:
|
|
||||||
m_serverProtocolConfig.insert(config_key::underloadPacketMagicHeader, value.toString());
|
|
||||||
break;
|
|
||||||
case Roles::ServerTransportPacketMagicHeaderRole:
|
|
||||||
m_serverProtocolConfig.insert(config_key::transportPacketMagicHeader, value.toString());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit dataChanged(index, index, QList { role });
|
emit dataChanged(index, index, QList { role });
|
||||||
@@ -58,22 +45,17 @@ QVariant AwgConfigModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::PortRole: return m_serverProtocolConfig.value(config_key::port).toString();
|
case Roles::PortRole: return m_protocolConfig.value(config_key::port).toString();
|
||||||
|
case Roles::MtuRole: return m_protocolConfig.value(config_key::mtu).toString();
|
||||||
case Roles::ClientMtuRole: return m_clientProtocolConfig.value(config_key::mtu);
|
case Roles::JunkPacketCountRole: return m_protocolConfig.value(config_key::junkPacketCount);
|
||||||
case Roles::ClientJunkPacketCountRole: return m_clientProtocolConfig.value(config_key::junkPacketCount);
|
case Roles::JunkPacketMinSizeRole: return m_protocolConfig.value(config_key::junkPacketMinSize);
|
||||||
case Roles::ClientJunkPacketMinSizeRole: return m_clientProtocolConfig.value(config_key::junkPacketMinSize);
|
case Roles::JunkPacketMaxSizeRole: return m_protocolConfig.value(config_key::junkPacketMaxSize);
|
||||||
case Roles::ClientJunkPacketMaxSizeRole: return m_clientProtocolConfig.value(config_key::junkPacketMaxSize);
|
case Roles::InitPacketJunkSizeRole: return m_protocolConfig.value(config_key::initPacketJunkSize);
|
||||||
|
case Roles::ResponsePacketJunkSizeRole: return m_protocolConfig.value(config_key::responsePacketJunkSize);
|
||||||
case Roles::ServerJunkPacketCountRole: return m_serverProtocolConfig.value(config_key::junkPacketCount);
|
case Roles::InitPacketMagicHeaderRole: return m_protocolConfig.value(config_key::initPacketMagicHeader);
|
||||||
case Roles::ServerJunkPacketMinSizeRole: return m_serverProtocolConfig.value(config_key::junkPacketMinSize);
|
case Roles::ResponsePacketMagicHeaderRole: return m_protocolConfig.value(config_key::responsePacketMagicHeader);
|
||||||
case Roles::ServerJunkPacketMaxSizeRole: return m_serverProtocolConfig.value(config_key::junkPacketMaxSize);
|
case Roles::UnderloadPacketMagicHeaderRole: return m_protocolConfig.value(config_key::underloadPacketMagicHeader);
|
||||||
case Roles::ServerInitPacketJunkSizeRole: return m_serverProtocolConfig.value(config_key::initPacketJunkSize);
|
case Roles::TransportPacketMagicHeaderRole: return m_protocolConfig.value(config_key::transportPacketMagicHeader);
|
||||||
case Roles::ServerResponsePacketJunkSizeRole: return m_serverProtocolConfig.value(config_key::responsePacketJunkSize);
|
|
||||||
case Roles::ServerInitPacketMagicHeaderRole: return m_serverProtocolConfig.value(config_key::initPacketMagicHeader);
|
|
||||||
case Roles::ServerResponsePacketMagicHeaderRole: return m_serverProtocolConfig.value(config_key::responsePacketMagicHeader);
|
|
||||||
case Roles::ServerUnderloadPacketMagicHeaderRole: return m_serverProtocolConfig.value(config_key::underloadPacketMagicHeader);
|
|
||||||
case Roles::ServerTransportPacketMagicHeaderRole: return m_serverProtocolConfig.value(config_key::transportPacketMagicHeader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -86,63 +68,51 @@ void AwgConfigModel::updateModel(const QJsonObject &config)
|
|||||||
|
|
||||||
m_fullConfig = config;
|
m_fullConfig = config;
|
||||||
|
|
||||||
QJsonObject serverProtocolConfig = config.value(config_key::awg).toObject();
|
QJsonObject protocolConfig = config.value(config_key::awg).toObject();
|
||||||
|
|
||||||
auto defaultTransportProto = ProtocolProps::transportProtoToString(ProtocolProps::defaultTransportProto(Proto::Awg), Proto::Awg);
|
auto defaultTransportProto = ProtocolProps::transportProtoToString(ProtocolProps::defaultTransportProto(Proto::Awg), Proto::Awg);
|
||||||
m_serverProtocolConfig.insert(config_key::transport_proto,
|
m_protocolConfig.insert(config_key::transport_proto, protocolConfig.value(config_key::transport_proto).toString(defaultTransportProto));
|
||||||
serverProtocolConfig.value(config_key::transport_proto).toString(defaultTransportProto));
|
m_protocolConfig[config_key::last_config] = protocolConfig.value(config_key::last_config);
|
||||||
m_serverProtocolConfig[config_key::last_config] = serverProtocolConfig.value(config_key::last_config);
|
m_protocolConfig[config_key::port] = protocolConfig.value(config_key::port).toString(protocols::awg::defaultPort);
|
||||||
m_serverProtocolConfig[config_key::port] = serverProtocolConfig.value(config_key::port).toString(protocols::awg::defaultPort);
|
m_protocolConfig[config_key::mtu] = protocolConfig.value(config_key::mtu).toString(protocols::awg::defaultMtu);
|
||||||
m_serverProtocolConfig[config_key::junkPacketCount] =
|
m_protocolConfig[config_key::junkPacketCount] =
|
||||||
serverProtocolConfig.value(config_key::junkPacketCount).toString(protocols::awg::defaultJunkPacketCount);
|
protocolConfig.value(config_key::junkPacketCount).toString(protocols::awg::defaultJunkPacketCount);
|
||||||
m_serverProtocolConfig[config_key::junkPacketMinSize] =
|
m_protocolConfig[config_key::junkPacketMinSize] =
|
||||||
serverProtocolConfig.value(config_key::junkPacketMinSize).toString(protocols::awg::defaultJunkPacketMinSize);
|
protocolConfig.value(config_key::junkPacketMinSize).toString(protocols::awg::defaultJunkPacketMinSize);
|
||||||
m_serverProtocolConfig[config_key::junkPacketMaxSize] =
|
m_protocolConfig[config_key::junkPacketMaxSize] =
|
||||||
serverProtocolConfig.value(config_key::junkPacketMaxSize).toString(protocols::awg::defaultJunkPacketMaxSize);
|
protocolConfig.value(config_key::junkPacketMaxSize).toString(protocols::awg::defaultJunkPacketMaxSize);
|
||||||
m_serverProtocolConfig[config_key::initPacketJunkSize] =
|
m_protocolConfig[config_key::initPacketJunkSize] =
|
||||||
serverProtocolConfig.value(config_key::initPacketJunkSize).toString(protocols::awg::defaultInitPacketJunkSize);
|
protocolConfig.value(config_key::initPacketJunkSize).toString(protocols::awg::defaultInitPacketJunkSize);
|
||||||
m_serverProtocolConfig[config_key::responsePacketJunkSize] =
|
m_protocolConfig[config_key::responsePacketJunkSize] =
|
||||||
serverProtocolConfig.value(config_key::responsePacketJunkSize).toString(protocols::awg::defaultResponsePacketJunkSize);
|
protocolConfig.value(config_key::responsePacketJunkSize).toString(protocols::awg::defaultResponsePacketJunkSize);
|
||||||
m_serverProtocolConfig[config_key::initPacketMagicHeader] =
|
m_protocolConfig[config_key::initPacketMagicHeader] =
|
||||||
serverProtocolConfig.value(config_key::initPacketMagicHeader).toString(protocols::awg::defaultInitPacketMagicHeader);
|
protocolConfig.value(config_key::initPacketMagicHeader).toString(protocols::awg::defaultInitPacketMagicHeader);
|
||||||
m_serverProtocolConfig[config_key::responsePacketMagicHeader] =
|
m_protocolConfig[config_key::responsePacketMagicHeader] =
|
||||||
serverProtocolConfig.value(config_key::responsePacketMagicHeader).toString(protocols::awg::defaultResponsePacketMagicHeader);
|
protocolConfig.value(config_key::responsePacketMagicHeader).toString(protocols::awg::defaultResponsePacketMagicHeader);
|
||||||
m_serverProtocolConfig[config_key::underloadPacketMagicHeader] =
|
m_protocolConfig[config_key::underloadPacketMagicHeader] =
|
||||||
serverProtocolConfig.value(config_key::underloadPacketMagicHeader).toString(protocols::awg::defaultUnderloadPacketMagicHeader);
|
protocolConfig.value(config_key::underloadPacketMagicHeader).toString(protocols::awg::defaultUnderloadPacketMagicHeader);
|
||||||
m_serverProtocolConfig[config_key::transportPacketMagicHeader] =
|
m_protocolConfig[config_key::transportPacketMagicHeader] =
|
||||||
serverProtocolConfig.value(config_key::transportPacketMagicHeader).toString(protocols::awg::defaultTransportPacketMagicHeader);
|
protocolConfig.value(config_key::transportPacketMagicHeader).toString(protocols::awg::defaultTransportPacketMagicHeader);
|
||||||
|
|
||||||
auto lastConfig = m_serverProtocolConfig.value(config_key::last_config).toString();
|
|
||||||
QJsonObject clientProtocolConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
|
||||||
m_clientProtocolConfig[config_key::mtu] = clientProtocolConfig[config_key::mtu].toString(protocols::awg::defaultMtu);
|
|
||||||
m_clientProtocolConfig[config_key::junkPacketCount] =
|
|
||||||
clientProtocolConfig.value(config_key::junkPacketCount).toString(m_serverProtocolConfig[config_key::junkPacketCount].toString());
|
|
||||||
m_clientProtocolConfig[config_key::junkPacketMinSize] =
|
|
||||||
clientProtocolConfig.value(config_key::junkPacketMinSize).toString(m_serverProtocolConfig[config_key::junkPacketMinSize].toString());
|
|
||||||
m_clientProtocolConfig[config_key::junkPacketMaxSize] =
|
|
||||||
clientProtocolConfig.value(config_key::junkPacketMaxSize).toString(m_serverProtocolConfig[config_key::junkPacketMaxSize].toString());
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject AwgConfigModel::getConfig()
|
QJsonObject AwgConfigModel::getConfig()
|
||||||
{
|
{
|
||||||
const AwgConfig oldConfig(m_fullConfig.value(config_key::awg).toObject());
|
const AwgConfig oldConfig(m_fullConfig.value(config_key::awg).toObject());
|
||||||
const AwgConfig newConfig(m_serverProtocolConfig);
|
const AwgConfig newConfig(m_protocolConfig);
|
||||||
|
|
||||||
if (!oldConfig.hasEqualServerSettings(newConfig)) {
|
if (!oldConfig.hasEqualServerSettings(newConfig)) {
|
||||||
m_serverProtocolConfig.remove(config_key::last_config);
|
m_protocolConfig.remove(config_key::last_config);
|
||||||
} else {
|
} else {
|
||||||
auto lastConfig = m_serverProtocolConfig.value(config_key::last_config).toString();
|
auto lastConfig = m_protocolConfig.value(config_key::last_config).toString();
|
||||||
QJsonObject jsonConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
QJsonObject jsonConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
||||||
jsonConfig[config_key::mtu] = m_clientProtocolConfig[config_key::mtu];
|
jsonConfig[config_key::mtu] = newConfig.mtu;
|
||||||
jsonConfig[config_key::junkPacketCount] = m_clientProtocolConfig[config_key::junkPacketCount];
|
|
||||||
jsonConfig[config_key::junkPacketMinSize] = m_clientProtocolConfig[config_key::junkPacketMinSize];
|
|
||||||
jsonConfig[config_key::junkPacketMaxSize] = m_clientProtocolConfig[config_key::junkPacketMaxSize];
|
|
||||||
|
|
||||||
m_serverProtocolConfig[config_key::last_config] = QString(QJsonDocument(jsonConfig).toJson());
|
m_protocolConfig[config_key::last_config] = QString(QJsonDocument(jsonConfig).toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fullConfig.insert(config_key::awg, m_serverProtocolConfig);
|
m_fullConfig.insert(config_key::awg, m_protocolConfig);
|
||||||
return m_fullConfig;
|
return m_fullConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,73 +126,50 @@ bool AwgConfigModel::isPacketSizeEqual(const int s1, const int s2)
|
|||||||
return (AwgConstant::messageInitiationSize + s1 == AwgConstant::messageResponseSize + s2);
|
return (AwgConstant::messageInitiationSize + s1 == AwgConstant::messageResponseSize + s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AwgConfigModel::isServerSettingsEqual()
|
|
||||||
{
|
|
||||||
const AwgConfig oldConfig(m_fullConfig.value(config_key::awg).toObject());
|
|
||||||
const AwgConfig newConfig(m_serverProtocolConfig);
|
|
||||||
|
|
||||||
return oldConfig.hasEqualServerSettings(newConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
QHash<int, QByteArray> AwgConfigModel::roleNames() const
|
QHash<int, QByteArray> AwgConfigModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
roles[PortRole] = "port";
|
roles[PortRole] = "port";
|
||||||
|
roles[MtuRole] = "mtu";
|
||||||
roles[ClientMtuRole] = "clientMtu";
|
roles[JunkPacketCountRole] = "junkPacketCount";
|
||||||
roles[ClientJunkPacketCountRole] = "clientJunkPacketCount";
|
roles[JunkPacketMinSizeRole] = "junkPacketMinSize";
|
||||||
roles[ClientJunkPacketMinSizeRole] = "clientJunkPacketMinSize";
|
roles[JunkPacketMaxSizeRole] = "junkPacketMaxSize";
|
||||||
roles[ClientJunkPacketMaxSizeRole] = "clientJunkPacketMaxSize";
|
roles[InitPacketJunkSizeRole] = "initPacketJunkSize";
|
||||||
|
roles[ResponsePacketJunkSizeRole] = "responsePacketJunkSize";
|
||||||
roles[ServerJunkPacketCountRole] = "serverJunkPacketCount";
|
roles[InitPacketMagicHeaderRole] = "initPacketMagicHeader";
|
||||||
roles[ServerJunkPacketMinSizeRole] = "serverJunkPacketMinSize";
|
roles[ResponsePacketMagicHeaderRole] = "responsePacketMagicHeader";
|
||||||
roles[ServerJunkPacketMaxSizeRole] = "serverJunkPacketMaxSize";
|
roles[UnderloadPacketMagicHeaderRole] = "underloadPacketMagicHeader";
|
||||||
roles[ServerInitPacketJunkSizeRole] = "serverInitPacketJunkSize";
|
roles[TransportPacketMagicHeaderRole] = "transportPacketMagicHeader";
|
||||||
roles[ServerResponsePacketJunkSizeRole] = "serverResponsePacketJunkSize";
|
|
||||||
roles[ServerInitPacketMagicHeaderRole] = "serverInitPacketMagicHeader";
|
|
||||||
roles[ServerResponsePacketMagicHeaderRole] = "serverResponsePacketMagicHeader";
|
|
||||||
roles[ServerUnderloadPacketMagicHeaderRole] = "serverUnderloadPacketMagicHeader";
|
|
||||||
roles[ServerTransportPacketMagicHeaderRole] = "serverTransportPacketMagicHeader";
|
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
AwgConfig::AwgConfig(const QJsonObject &serverProtocolConfig)
|
AwgConfig::AwgConfig(const QJsonObject &jsonConfig)
|
||||||
{
|
{
|
||||||
auto lastConfig = serverProtocolConfig.value(config_key::last_config).toString();
|
port = jsonConfig.value(config_key::port).toString(protocols::awg::defaultPort);
|
||||||
QJsonObject clientProtocolConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
mtu = jsonConfig.value(config_key::mtu).toString(protocols::awg::defaultMtu);
|
||||||
clientMtu = clientProtocolConfig[config_key::mtu].toString(protocols::awg::defaultMtu);
|
junkPacketCount = jsonConfig.value(config_key::junkPacketCount).toString(protocols::awg::defaultJunkPacketCount);
|
||||||
clientJunkPacketCount = clientProtocolConfig.value(config_key::junkPacketCount).toString(protocols::awg::defaultJunkPacketCount);
|
junkPacketMinSize = jsonConfig.value(config_key::junkPacketMinSize).toString(protocols::awg::defaultJunkPacketMinSize);
|
||||||
clientJunkPacketMinSize = clientProtocolConfig.value(config_key::junkPacketMinSize).toString(protocols::awg::defaultJunkPacketMinSize);
|
junkPacketMaxSize = jsonConfig.value(config_key::junkPacketMaxSize).toString(protocols::awg::defaultJunkPacketMaxSize);
|
||||||
clientJunkPacketMaxSize = clientProtocolConfig.value(config_key::junkPacketMaxSize).toString(protocols::awg::defaultJunkPacketMaxSize);
|
initPacketJunkSize = jsonConfig.value(config_key::initPacketJunkSize).toString(protocols::awg::defaultInitPacketJunkSize);
|
||||||
|
responsePacketJunkSize = jsonConfig.value(config_key::responsePacketJunkSize).toString(protocols::awg::defaultResponsePacketJunkSize);
|
||||||
port = serverProtocolConfig.value(config_key::port).toString(protocols::awg::defaultPort);
|
initPacketMagicHeader = jsonConfig.value(config_key::initPacketMagicHeader).toString(protocols::awg::defaultInitPacketMagicHeader);
|
||||||
serverJunkPacketCount = serverProtocolConfig.value(config_key::junkPacketCount).toString(protocols::awg::defaultJunkPacketCount);
|
responsePacketMagicHeader =
|
||||||
serverJunkPacketMinSize = serverProtocolConfig.value(config_key::junkPacketMinSize).toString(protocols::awg::defaultJunkPacketMinSize);
|
jsonConfig.value(config_key::responsePacketMagicHeader).toString(protocols::awg::defaultResponsePacketMagicHeader);
|
||||||
serverJunkPacketMaxSize = serverProtocolConfig.value(config_key::junkPacketMaxSize).toString(protocols::awg::defaultJunkPacketMaxSize);
|
underloadPacketMagicHeader =
|
||||||
serverInitPacketJunkSize = serverProtocolConfig.value(config_key::initPacketJunkSize).toString(protocols::awg::defaultInitPacketJunkSize);
|
jsonConfig.value(config_key::underloadPacketMagicHeader).toString(protocols::awg::defaultUnderloadPacketMagicHeader);
|
||||||
serverResponsePacketJunkSize =
|
transportPacketMagicHeader =
|
||||||
serverProtocolConfig.value(config_key::responsePacketJunkSize).toString(protocols::awg::defaultResponsePacketJunkSize);
|
jsonConfig.value(config_key::transportPacketMagicHeader).toString(protocols::awg::defaultTransportPacketMagicHeader);
|
||||||
serverInitPacketMagicHeader =
|
|
||||||
serverProtocolConfig.value(config_key::initPacketMagicHeader).toString(protocols::awg::defaultInitPacketMagicHeader);
|
|
||||||
serverResponsePacketMagicHeader =
|
|
||||||
serverProtocolConfig.value(config_key::responsePacketMagicHeader).toString(protocols::awg::defaultResponsePacketMagicHeader);
|
|
||||||
serverUnderloadPacketMagicHeader =
|
|
||||||
serverProtocolConfig.value(config_key::underloadPacketMagicHeader).toString(protocols::awg::defaultUnderloadPacketMagicHeader);
|
|
||||||
serverTransportPacketMagicHeader =
|
|
||||||
serverProtocolConfig.value(config_key::transportPacketMagicHeader).toString(protocols::awg::defaultTransportPacketMagicHeader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AwgConfig::hasEqualServerSettings(const AwgConfig &other) const
|
bool AwgConfig::hasEqualServerSettings(const AwgConfig &other) const
|
||||||
{
|
{
|
||||||
if (port != other.port || serverJunkPacketCount != other.serverJunkPacketCount
|
if (port != other.port || junkPacketCount != other.junkPacketCount || junkPacketMinSize != other.junkPacketMinSize
|
||||||
|| serverJunkPacketMinSize != other.serverJunkPacketMinSize || serverJunkPacketMaxSize != other.serverJunkPacketMaxSize
|
|| junkPacketMaxSize != other.junkPacketMaxSize || initPacketJunkSize != other.initPacketJunkSize
|
||||||
|| serverInitPacketJunkSize != other.serverInitPacketJunkSize || serverResponsePacketJunkSize != other.serverResponsePacketJunkSize
|
|| responsePacketJunkSize != other.responsePacketJunkSize || initPacketMagicHeader != other.initPacketMagicHeader
|
||||||
|| serverInitPacketMagicHeader != other.serverInitPacketMagicHeader
|
|| responsePacketMagicHeader != other.responsePacketMagicHeader || underloadPacketMagicHeader != other.underloadPacketMagicHeader
|
||||||
|| serverResponsePacketMagicHeader != other.serverResponsePacketMagicHeader
|
|| transportPacketMagicHeader != other.transportPacketMagicHeader) {
|
||||||
|| serverUnderloadPacketMagicHeader != other.serverUnderloadPacketMagicHeader
|
|
||||||
|| serverTransportPacketMagicHeader != other.serverTransportPacketMagicHeader) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -230,8 +177,7 @@ bool AwgConfig::hasEqualServerSettings(const AwgConfig &other) const
|
|||||||
|
|
||||||
bool AwgConfig::hasEqualClientSettings(const AwgConfig &other) const
|
bool AwgConfig::hasEqualClientSettings(const AwgConfig &other) const
|
||||||
{
|
{
|
||||||
if (clientMtu != other.clientMtu || clientJunkPacketCount != other.clientJunkPacketCount
|
if (mtu != other.mtu) {
|
||||||
|| clientJunkPacketMinSize != other.clientJunkPacketMinSize || clientJunkPacketMaxSize != other.clientJunkPacketMaxSize) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -16,21 +16,16 @@ struct AwgConfig
|
|||||||
AwgConfig(const QJsonObject &jsonConfig);
|
AwgConfig(const QJsonObject &jsonConfig);
|
||||||
|
|
||||||
QString port;
|
QString port;
|
||||||
|
QString mtu;
|
||||||
QString clientMtu;
|
QString junkPacketCount;
|
||||||
QString clientJunkPacketCount;
|
QString junkPacketMinSize;
|
||||||
QString clientJunkPacketMinSize;
|
QString junkPacketMaxSize;
|
||||||
QString clientJunkPacketMaxSize;
|
QString initPacketJunkSize;
|
||||||
|
QString responsePacketJunkSize;
|
||||||
QString serverJunkPacketCount;
|
QString initPacketMagicHeader;
|
||||||
QString serverJunkPacketMinSize;
|
QString responsePacketMagicHeader;
|
||||||
QString serverJunkPacketMaxSize;
|
QString underloadPacketMagicHeader;
|
||||||
QString serverInitPacketJunkSize;
|
QString transportPacketMagicHeader;
|
||||||
QString serverResponsePacketJunkSize;
|
|
||||||
QString serverInitPacketMagicHeader;
|
|
||||||
QString serverResponsePacketMagicHeader;
|
|
||||||
QString serverUnderloadPacketMagicHeader;
|
|
||||||
QString serverTransportPacketMagicHeader;
|
|
||||||
|
|
||||||
bool hasEqualServerSettings(const AwgConfig &other) const;
|
bool hasEqualServerSettings(const AwgConfig &other) const;
|
||||||
bool hasEqualClientSettings(const AwgConfig &other) const;
|
bool hasEqualClientSettings(const AwgConfig &other) const;
|
||||||
@@ -44,21 +39,16 @@ class AwgConfigModel : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
PortRole = Qt::UserRole + 1,
|
PortRole = Qt::UserRole + 1,
|
||||||
|
MtuRole,
|
||||||
ClientMtuRole,
|
JunkPacketCountRole,
|
||||||
ClientJunkPacketCountRole,
|
JunkPacketMinSizeRole,
|
||||||
ClientJunkPacketMinSizeRole,
|
JunkPacketMaxSizeRole,
|
||||||
ClientJunkPacketMaxSizeRole,
|
InitPacketJunkSizeRole,
|
||||||
|
ResponsePacketJunkSizeRole,
|
||||||
ServerJunkPacketCountRole,
|
InitPacketMagicHeaderRole,
|
||||||
ServerJunkPacketMinSizeRole,
|
ResponsePacketMagicHeaderRole,
|
||||||
ServerJunkPacketMaxSizeRole,
|
UnderloadPacketMagicHeaderRole,
|
||||||
ServerInitPacketJunkSizeRole,
|
TransportPacketMagicHeaderRole
|
||||||
ServerResponsePacketJunkSizeRole,
|
|
||||||
ServerInitPacketMagicHeaderRole,
|
|
||||||
ServerResponsePacketMagicHeaderRole,
|
|
||||||
ServerUnderloadPacketMagicHeaderRole,
|
|
||||||
ServerTransportPacketMagicHeaderRole
|
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit AwgConfigModel(QObject *parent = nullptr);
|
explicit AwgConfigModel(QObject *parent = nullptr);
|
||||||
@@ -75,15 +65,12 @@ public slots:
|
|||||||
bool isHeadersEqual(const QString &h1, const QString &h2, const QString &h3, const QString &h4);
|
bool isHeadersEqual(const QString &h1, const QString &h2, const QString &h3, const QString &h4);
|
||||||
bool isPacketSizeEqual(const int s1, const int s2);
|
bool isPacketSizeEqual(const int s1, const int s2);
|
||||||
|
|
||||||
bool isServerSettingsEqual();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DockerContainer m_container;
|
DockerContainer m_container;
|
||||||
QJsonObject m_serverProtocolConfig;
|
QJsonObject m_protocolConfig;
|
||||||
QJsonObject m_clientProtocolConfig;
|
|
||||||
QJsonObject m_fullConfig;
|
QJsonObject m_fullConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ bool WireGuardConfigModel::setData(const QModelIndex &index, const QVariant &val
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::PortRole: m_serverProtocolConfig.insert(config_key::port, value.toString()); break;
|
case Roles::PortRole: m_protocolConfig.insert(config_key::port, value.toString()); break;
|
||||||
case Roles::ClientMtuRole: m_clientProtocolConfig.insert(config_key::mtu, value.toString()); break;
|
case Roles::MtuRole: m_protocolConfig.insert(config_key::mtu, value.toString()); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit dataChanged(index, index, QList { role });
|
emit dataChanged(index, index, QList { role });
|
||||||
@@ -36,8 +36,8 @@ QVariant WireGuardConfigModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::PortRole: return m_serverProtocolConfig.value(config_key::port).toString();
|
case Roles::PortRole: return m_protocolConfig.value(config_key::port).toString();
|
||||||
case Roles::ClientMtuRole: return m_clientProtocolConfig.value(config_key::mtu);
|
case Roles::MtuRole: return m_protocolConfig.value(config_key::mtu).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -49,18 +49,17 @@ void WireGuardConfigModel::updateModel(const QJsonObject &config)
|
|||||||
m_container = ContainerProps::containerFromString(config.value(config_key::container).toString());
|
m_container = ContainerProps::containerFromString(config.value(config_key::container).toString());
|
||||||
|
|
||||||
m_fullConfig = config;
|
m_fullConfig = config;
|
||||||
QJsonObject serverProtocolConfig = config.value(config_key::wireguard).toObject();
|
QJsonObject protocolConfig = config.value(config_key::wireguard).toObject();
|
||||||
|
|
||||||
auto defaultTransportProto =
|
auto defaultTransportProto = ProtocolProps::transportProtoToString(ProtocolProps::defaultTransportProto(Proto::WireGuard), Proto::WireGuard);
|
||||||
ProtocolProps::transportProtoToString(ProtocolProps::defaultTransportProto(Proto::WireGuard), Proto::WireGuard);
|
m_protocolConfig.insert(config_key::transport_proto,
|
||||||
m_serverProtocolConfig.insert(config_key::transport_proto,
|
protocolConfig.value(config_key::transport_proto).toString(defaultTransportProto));
|
||||||
serverProtocolConfig.value(config_key::transport_proto).toString(defaultTransportProto));
|
m_protocolConfig[config_key::last_config] = protocolConfig.value(config_key::last_config);
|
||||||
m_serverProtocolConfig[config_key::last_config] = serverProtocolConfig.value(config_key::last_config);
|
m_protocolConfig[config_key::port] =
|
||||||
m_serverProtocolConfig[config_key::port] = serverProtocolConfig.value(config_key::port).toString(protocols::wireguard::defaultPort);
|
protocolConfig.value(config_key::port).toString(protocols::wireguard::defaultPort);
|
||||||
|
|
||||||
auto lastConfig = m_serverProtocolConfig.value(config_key::last_config).toString();
|
m_protocolConfig[config_key::mtu] =
|
||||||
QJsonObject clientProtocolConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
protocolConfig.value(config_key::mtu).toString(protocols::wireguard::defaultMtu);
|
||||||
m_clientProtocolConfig[config_key::mtu] = clientProtocolConfig[config_key::mtu].toString(protocols::wireguard::defaultMtu);
|
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
@@ -68,47 +67,36 @@ void WireGuardConfigModel::updateModel(const QJsonObject &config)
|
|||||||
QJsonObject WireGuardConfigModel::getConfig()
|
QJsonObject WireGuardConfigModel::getConfig()
|
||||||
{
|
{
|
||||||
const WgConfig oldConfig(m_fullConfig.value(config_key::wireguard).toObject());
|
const WgConfig oldConfig(m_fullConfig.value(config_key::wireguard).toObject());
|
||||||
const WgConfig newConfig(m_serverProtocolConfig);
|
const WgConfig newConfig(m_protocolConfig);
|
||||||
|
|
||||||
if (!oldConfig.hasEqualServerSettings(newConfig)) {
|
if (!oldConfig.hasEqualServerSettings(newConfig)) {
|
||||||
m_serverProtocolConfig.remove(config_key::last_config);
|
m_protocolConfig.remove(config_key::last_config);
|
||||||
} else {
|
} else {
|
||||||
auto lastConfig = m_serverProtocolConfig.value(config_key::last_config).toString();
|
auto lastConfig = m_protocolConfig.value(config_key::last_config).toString();
|
||||||
QJsonObject jsonConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
QJsonObject jsonConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
||||||
jsonConfig[config_key::mtu] = m_clientProtocolConfig[config_key::mtu];
|
jsonConfig[config_key::mtu] = newConfig.mtu;
|
||||||
|
|
||||||
m_serverProtocolConfig[config_key::last_config] = QString(QJsonDocument(jsonConfig).toJson());
|
m_protocolConfig[config_key::last_config] = QString(QJsonDocument(jsonConfig).toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fullConfig.insert(config_key::wireguard, m_serverProtocolConfig);
|
m_fullConfig.insert(config_key::wireguard, m_protocolConfig);
|
||||||
return m_fullConfig;
|
return m_fullConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WireGuardConfigModel::isServerSettingsEqual()
|
|
||||||
{
|
|
||||||
const WgConfig oldConfig(m_fullConfig.value(config_key::wireguard).toObject());
|
|
||||||
const WgConfig newConfig(m_serverProtocolConfig);
|
|
||||||
|
|
||||||
return oldConfig.hasEqualServerSettings(newConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
QHash<int, QByteArray> WireGuardConfigModel::roleNames() const
|
QHash<int, QByteArray> WireGuardConfigModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
roles[PortRole] = "port";
|
roles[PortRole] = "port";
|
||||||
roles[ClientMtuRole] = "clientMtu";
|
roles[MtuRole] = "mtu";
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
WgConfig::WgConfig(const QJsonObject &serverProtocolConfig)
|
WgConfig::WgConfig(const QJsonObject &jsonConfig)
|
||||||
{
|
{
|
||||||
auto lastConfig = serverProtocolConfig.value(config_key::last_config).toString();
|
port = jsonConfig.value(config_key::port).toString(protocols::wireguard::defaultPort);
|
||||||
QJsonObject clientProtocolConfig = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
|
mtu = jsonConfig.value(config_key::mtu).toString(protocols::wireguard::defaultMtu);
|
||||||
clientMtu = clientProtocolConfig[config_key::mtu].toString(protocols::wireguard::defaultMtu);
|
|
||||||
|
|
||||||
port = serverProtocolConfig.value(config_key::port).toString(protocols::wireguard::defaultPort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WgConfig::hasEqualServerSettings(const WgConfig &other) const
|
bool WgConfig::hasEqualServerSettings(const WgConfig &other) const
|
||||||
@@ -121,7 +109,7 @@ bool WgConfig::hasEqualServerSettings(const WgConfig &other) const
|
|||||||
|
|
||||||
bool WgConfig::hasEqualClientSettings(const WgConfig &other) const
|
bool WgConfig::hasEqualClientSettings(const WgConfig &other) const
|
||||||
{
|
{
|
||||||
if (clientMtu != other.clientMtu) {
|
if (mtu != other.mtu) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ struct WgConfig
|
|||||||
WgConfig(const QJsonObject &jsonConfig);
|
WgConfig(const QJsonObject &jsonConfig);
|
||||||
|
|
||||||
QString port;
|
QString port;
|
||||||
QString clientMtu;
|
QString mtu;
|
||||||
|
|
||||||
bool hasEqualServerSettings(const WgConfig &other) const;
|
bool hasEqualServerSettings(const WgConfig &other) const;
|
||||||
bool hasEqualClientSettings(const WgConfig &other) const;
|
bool hasEqualClientSettings(const WgConfig &other) const;
|
||||||
@@ -25,7 +25,7 @@ class WireGuardConfigModel : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
PortRole = Qt::UserRole + 1,
|
PortRole = Qt::UserRole + 1,
|
||||||
ClientMtuRole
|
MtuRole
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit WireGuardConfigModel(QObject *parent = nullptr);
|
explicit WireGuardConfigModel(QObject *parent = nullptr);
|
||||||
@@ -39,15 +39,12 @@ public slots:
|
|||||||
void updateModel(const QJsonObject &config);
|
void updateModel(const QJsonObject &config);
|
||||||
QJsonObject getConfig();
|
QJsonObject getConfig();
|
||||||
|
|
||||||
bool isServerSettingsEqual();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DockerContainer m_container;
|
DockerContainer m_container;
|
||||||
QJsonObject m_serverProtocolConfig;
|
QJsonObject m_protocolConfig;
|
||||||
QJsonObject m_clientProtocolConfig;
|
|
||||||
QJsonObject m_fullConfig;
|
QJsonObject m_fullConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,9 @@ QHash<int, QByteArray> ProtocolsModel::roleNames() const
|
|||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
roles[ProtocolNameRole] = "protocolName";
|
roles[ProtocolNameRole] = "protocolName";
|
||||||
roles[ServerProtocolPageRole] = "serverProtocolPage";
|
roles[ProtocolPageRole] = "protocolPage";
|
||||||
roles[ClientProtocolPageRole] = "clientProtocolPage";
|
|
||||||
roles[ProtocolIndexRole] = "protocolIndex";
|
roles[ProtocolIndexRole] = "protocolIndex";
|
||||||
roles[RawConfigRole] = "rawConfig";
|
roles[RawConfigRole] = "rawConfig";
|
||||||
roles[IsClientProtocolExistsRole] = "isClientProtocolExists";
|
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
@@ -36,10 +34,8 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
|||||||
amnezia::Proto proto = ProtocolProps::protoFromString(m_content.keys().at(index.row()));
|
amnezia::Proto proto = ProtocolProps::protoFromString(m_content.keys().at(index.row()));
|
||||||
return ProtocolProps::protocolHumanNames().value(proto);
|
return ProtocolProps::protocolHumanNames().value(proto);
|
||||||
}
|
}
|
||||||
case ServerProtocolPageRole:
|
case ProtocolPageRole:
|
||||||
return static_cast<int>(serverProtocolPage(ProtocolProps::protoFromString(m_content.keys().at(index.row()))));
|
return static_cast<int>(protocolPage(ProtocolProps::protoFromString(m_content.keys().at(index.row()))));
|
||||||
case ClientProtocolPageRole:
|
|
||||||
return static_cast<int>(clientProtocolPage(ProtocolProps::protoFromString(m_content.keys().at(index.row()))));
|
|
||||||
case ProtocolIndexRole: return ProtocolProps::protoFromString(m_content.keys().at(index.row()));
|
case ProtocolIndexRole: return ProtocolProps::protoFromString(m_content.keys().at(index.row()));
|
||||||
case RawConfigRole: {
|
case RawConfigRole: {
|
||||||
auto protocolConfig = m_content.value(ContainerProps::containerTypeToString(m_container)).toObject();
|
auto protocolConfig = m_content.value(ContainerProps::containerTypeToString(m_container)).toObject();
|
||||||
@@ -54,15 +50,6 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
return rawConfig;
|
return rawConfig;
|
||||||
}
|
}
|
||||||
case IsClientProtocolExistsRole: {
|
|
||||||
auto protocolConfig = m_content.value(ContainerProps::containerTypeToString(m_container)).toObject();
|
|
||||||
auto lastConfigJsonDoc =
|
|
||||||
QJsonDocument::fromJson(protocolConfig.value(config_key::last_config).toString().toUtf8());
|
|
||||||
auto lastConfigJson = lastConfigJsonDoc.object();
|
|
||||||
|
|
||||||
auto configString = lastConfigJson.value(config_key::config).toString();
|
|
||||||
return !configString.isEmpty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -83,7 +70,7 @@ QJsonObject ProtocolsModel::getConfig()
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageLoader::PageEnum ProtocolsModel::serverProtocolPage(Proto protocol) const
|
PageLoader::PageEnum ProtocolsModel::protocolPage(Proto protocol) const
|
||||||
{
|
{
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
case Proto::OpenVpn: return PageLoader::PageEnum::PageProtocolOpenVpnSettings;
|
case Proto::OpenVpn: return PageLoader::PageEnum::PageProtocolOpenVpnSettings;
|
||||||
@@ -103,12 +90,3 @@ PageLoader::PageEnum ProtocolsModel::serverProtocolPage(Proto protocol) const
|
|||||||
default: return PageLoader::PageEnum::PageProtocolOpenVpnSettings;
|
default: return PageLoader::PageEnum::PageProtocolOpenVpnSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PageLoader::PageEnum ProtocolsModel::clientProtocolPage(Proto protocol) const
|
|
||||||
{
|
|
||||||
switch (protocol) {
|
|
||||||
case Proto::WireGuard: return PageLoader::PageEnum::PageProtocolWireGuardClientSettings;
|
|
||||||
case Proto::Awg: return PageLoader::PageEnum::PageProtocolAwgClientSettings;
|
|
||||||
default: return PageLoader::PageEnum::PageProtocolOpenVpnSettings;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ class ProtocolsModel : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
ProtocolNameRole = Qt::UserRole + 1,
|
ProtocolNameRole = Qt::UserRole + 1,
|
||||||
ServerProtocolPageRole,
|
ProtocolPageRole,
|
||||||
ClientProtocolPageRole,
|
|
||||||
ProtocolIndexRole,
|
ProtocolIndexRole,
|
||||||
RawConfigRole,
|
RawConfigRole
|
||||||
IsClientProtocolExistsRole
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||||
@@ -35,8 +33,7 @@ protected:
|
|||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PageLoader::PageEnum serverProtocolPage(Proto protocol) const;
|
PageLoader::PageEnum protocolPage(Proto protocol) const;
|
||||||
PageLoader::PageEnum clientProtocolPage(Proto protocol) const;
|
|
||||||
|
|
||||||
std::shared_ptr<Settings> m_settings;
|
std::shared_ptr<Settings> m_settings;
|
||||||
|
|
||||||
|
|||||||
@@ -1,312 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
|
||||||
|
|
||||||
import PageEnum 1.0
|
|
||||||
|
|
||||||
import "./"
|
|
||||||
import "../Controls2"
|
|
||||||
import "../Controls2/TextTypes"
|
|
||||||
import "../Config"
|
|
||||||
import "../Components"
|
|
||||||
|
|
||||||
|
|
||||||
PageType {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
defaultActiveFocusItem: listview.currentItem.mtuTextField.textField
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: focusItem
|
|
||||||
onFocusChanged: {
|
|
||||||
if (activeFocus) {
|
|
||||||
fl.ensureVisible(focusItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KeyNavigation.tab: backButton
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: backButtonLayout
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
anchors.topMargin: 20
|
|
||||||
|
|
||||||
BackButtonType {
|
|
||||||
id: backButton
|
|
||||||
KeyNavigation.tab: listview.currentItem.mtuTextField.textField
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FlickableType {
|
|
||||||
id: fl
|
|
||||||
anchors.top: backButtonLayout.bottom
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
contentHeight: content.implicitHeight + saveButton.implicitHeight + saveButton.anchors.bottomMargin + saveButton.anchors.topMargin
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: content
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: listview
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
height: listview.contentItem.height
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
interactive: false
|
|
||||||
|
|
||||||
model: AwgConfigModel
|
|
||||||
|
|
||||||
delegate: Item {
|
|
||||||
id: delegateItem
|
|
||||||
implicitWidth: listview.width
|
|
||||||
implicitHeight: col.implicitHeight
|
|
||||||
|
|
||||||
property alias mtuTextField: mtuTextField
|
|
||||||
property bool isSaveButtonEnabled: mtuTextField.errorText === "" &&
|
|
||||||
junkPacketMaxSizeTextField.errorText === "" &&
|
|
||||||
junkPacketMinSizeTextField.errorText === "" &&
|
|
||||||
junkPacketCountTextField.errorText === ""
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: col
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
anchors.leftMargin: 16
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
HeaderType {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
headerText: qsTr("AmneziaWG settings")
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: mtuTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 40
|
|
||||||
|
|
||||||
headerText: qsTr("MTU")
|
|
||||||
textFieldText: clientMtu
|
|
||||||
textField.validator: IntValidator { bottom: 576; top: 65535 }
|
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
|
||||||
if (textFieldText !== clientMtu) {
|
|
||||||
clientMtu = textFieldText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkEmptyText: true
|
|
||||||
KeyNavigation.tab: junkPacketCountTextField.textField
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: junkPacketCountTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
headerText: "Jc - Junk packet count"
|
|
||||||
textFieldText: clientJunkPacketCount
|
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
|
||||||
if (textFieldText !== clientJunkPacketCount) {
|
|
||||||
clientJunkPacketCount = textFieldText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEmptyText: true
|
|
||||||
|
|
||||||
KeyNavigation.tab: junkPacketMinSizeTextField.textField
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: junkPacketMinSizeTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
headerText: "Jmin - Junk packet minimum size"
|
|
||||||
textFieldText: clientJunkPacketMinSize
|
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
|
||||||
if (textFieldText !== clientJunkPacketMinSize) {
|
|
||||||
clientJunkPacketMinSize = textFieldText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEmptyText: true
|
|
||||||
|
|
||||||
KeyNavigation.tab: junkPacketMaxSizeTextField.textField
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: junkPacketMaxSizeTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
headerText: "Jmax - Junk packet maximum size"
|
|
||||||
textFieldText: clientJunkPacketMaxSize
|
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
|
||||||
if (textFieldText !== clientJunkPacketMaxSize) {
|
|
||||||
clientJunkPacketMaxSize = textFieldText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEmptyText: true
|
|
||||||
|
|
||||||
Keys.onTabPressed: saveButton.forceActiveFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
Header2TextType {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
text: qsTr("Server settings")
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: portTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 8
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
|
||||||
textFieldText: port
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: initPacketJunkSizeTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: "S1 - Init packet junk size"
|
|
||||||
textFieldText: serverInitPacketJunkSize
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: responsePacketJunkSizeTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: "S2 - Response packet junk size"
|
|
||||||
textFieldText: serverResponsePacketJunkSize
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: initPacketMagicHeaderTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: "H1 - Init packet magic header"
|
|
||||||
textFieldText: serverInitPacketMagicHeader
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: responsePacketMagicHeaderTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: "H2 - Response packet magic header"
|
|
||||||
textFieldText: serverResponsePacketMagicHeader
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: underloadPacketMagicHeaderTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
parentFlickable: fl
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: "H3 - Underload packet magic header"
|
|
||||||
textFieldText: serverUnderloadPacketMagicHeader
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: transportPacketMagicHeaderTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: "H4 - Transport packet magic header"
|
|
||||||
textFieldText: serverTransportPacketMagicHeader
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BasicButtonType {
|
|
||||||
id: saveButton
|
|
||||||
|
|
||||||
anchors.right: root.right
|
|
||||||
anchors.left: root.left
|
|
||||||
anchors.bottom: root.bottom
|
|
||||||
|
|
||||||
anchors.topMargin: 24
|
|
||||||
anchors.bottomMargin: 24
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
anchors.leftMargin: 16
|
|
||||||
|
|
||||||
enabled: listview.currentItem.isSaveButtonEnabled
|
|
||||||
|
|
||||||
text: qsTr("Save")
|
|
||||||
|
|
||||||
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
|
||||||
|
|
||||||
clickedFunc: function() {
|
|
||||||
forceActiveFocus()
|
|
||||||
var headerText = qsTr("Save settings?")
|
|
||||||
var descriptionText = qsTr("Only the settings for this device will be changed")
|
|
||||||
var yesButtonText = qsTr("Continue")
|
|
||||||
var noButtonText = qsTr("Cancel")
|
|
||||||
|
|
||||||
var yesButtonFunction = function() {
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
|
||||||
InstallController.updateContainer(AwgConfigModel.getConfig())
|
|
||||||
}
|
|
||||||
var noButtonFunction = function() {
|
|
||||||
if (!GC.isMobile()) {
|
|
||||||
saveButton.forceActiveFocus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -57,6 +57,8 @@ PageType {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
enabled: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listview
|
id: listview
|
||||||
|
|
||||||
@@ -69,12 +71,12 @@ PageType {
|
|||||||
model: AwgConfigModel
|
model: AwgConfigModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: delegateItem
|
id: _delegate
|
||||||
|
|
||||||
implicitWidth: listview.width
|
implicitWidth: listview.width
|
||||||
implicitHeight: col.implicitHeight
|
implicitHeight: col.implicitHeight
|
||||||
|
|
||||||
property alias portTextField: portTextField
|
property alias portTextField:portTextField
|
||||||
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: col
|
id: col
|
||||||
@@ -99,8 +101,6 @@ PageType {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
|
|
||||||
enabled: delegateItem.isEnabled
|
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textFieldText: port
|
textFieldText: port
|
||||||
textField.maximumLength: 5
|
textField.maximumLength: 5
|
||||||
@@ -115,6 +115,27 @@ PageType {
|
|||||||
|
|
||||||
checkEmptyText: true
|
checkEmptyText: true
|
||||||
|
|
||||||
|
KeyNavigation.tab: mtuTextField.textField
|
||||||
|
}
|
||||||
|
|
||||||
|
TextFieldWithHeaderType {
|
||||||
|
id: mtuTextField
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
|
|
||||||
|
headerText: qsTr("MTU")
|
||||||
|
textFieldText: mtu
|
||||||
|
textField.validator: IntValidator { bottom: 576; top: 65535 }
|
||||||
|
|
||||||
|
textField.onEditingFinished: {
|
||||||
|
if (textFieldText === "") {
|
||||||
|
textFieldText = "0"
|
||||||
|
}
|
||||||
|
if (textFieldText !== mtu) {
|
||||||
|
mtu = textFieldText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkEmptyText: true
|
||||||
KeyNavigation.tab: junkPacketCountTextField.textField
|
KeyNavigation.tab: junkPacketCountTextField.textField
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +145,7 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("Jc - Junk packet count")
|
headerText: qsTr("Jc - Junk packet count")
|
||||||
textFieldText: serverJunkPacketCount
|
textFieldText: junkPacketCount
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
@@ -133,8 +154,8 @@ PageType {
|
|||||||
textFieldText = "0"
|
textFieldText = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textFieldText !== serverJunkPacketCount) {
|
if (textFieldText !== junkPacketCount) {
|
||||||
serverJunkPacketCount = textFieldText
|
junkPacketCount = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,13 +170,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("Jmin - Junk packet minimum size")
|
headerText: qsTr("Jmin - Junk packet minimum size")
|
||||||
textFieldText: serverJunkPacketMinSize
|
textFieldText: junkPacketMinSize
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverJunkPacketMinSize) {
|
if (textFieldText !== junkPacketMinSize) {
|
||||||
serverJunkPacketMinSize = textFieldText
|
junkPacketMinSize = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,13 +191,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("Jmax - Junk packet maximum size")
|
headerText: qsTr("Jmax - Junk packet maximum size")
|
||||||
textFieldText: serverJunkPacketMaxSize
|
textFieldText: junkPacketMaxSize
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverJunkPacketMaxSize) {
|
if (textFieldText !== junkPacketMaxSize) {
|
||||||
serverJunkPacketMaxSize = textFieldText
|
junkPacketMaxSize = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +212,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("S1 - Init packet junk size")
|
headerText: qsTr("S1 - Init packet junk size")
|
||||||
textFieldText: serverInitPacketJunkSize
|
textFieldText: initPacketJunkSize
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverInitPacketJunkSize) {
|
if (textFieldText !== initPacketJunkSize) {
|
||||||
serverInitPacketJunkSize = textFieldText
|
initPacketJunkSize = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,13 +233,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("S2 - Response packet junk size")
|
headerText: qsTr("S2 - Response packet junk size")
|
||||||
textFieldText: serverResponsePacketJunkSize
|
textFieldText: responsePacketJunkSize
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverResponsePacketJunkSize) {
|
if (textFieldText !== responsePacketJunkSize) {
|
||||||
serverResponsePacketJunkSize = textFieldText
|
responsePacketJunkSize = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,13 +254,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("H1 - Init packet magic header")
|
headerText: qsTr("H1 - Init packet magic header")
|
||||||
textFieldText: serverInitPacketMagicHeader
|
textFieldText: initPacketMagicHeader
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverInitPacketMagicHeader) {
|
if (textFieldText !== initPacketMagicHeader) {
|
||||||
serverInitPacketMagicHeader = textFieldText
|
initPacketMagicHeader = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,13 +275,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("H2 - Response packet magic header")
|
headerText: qsTr("H2 - Response packet magic header")
|
||||||
textFieldText: serverResponsePacketMagicHeader
|
textFieldText: responsePacketMagicHeader
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverResponsePacketMagicHeader) {
|
if (textFieldText !== responsePacketMagicHeader) {
|
||||||
serverResponsePacketMagicHeader = textFieldText
|
responsePacketMagicHeader = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,13 +296,13 @@ PageType {
|
|||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
headerText: qsTr("H4 - Transport packet magic header")
|
headerText: qsTr("H4 - Transport packet magic header")
|
||||||
textFieldText: serverTransportPacketMagicHeader
|
textFieldText: transportPacketMagicHeader
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverTransportPacketMagicHeader) {
|
if (textFieldText !== transportPacketMagicHeader) {
|
||||||
serverTransportPacketMagicHeader = textFieldText
|
transportPacketMagicHeader = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,12 +318,12 @@ PageType {
|
|||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
headerText: qsTr("H3 - Underload packet magic header")
|
headerText: qsTr("H3 - Underload packet magic header")
|
||||||
textFieldText: serverUnderloadPacketMagicHeader
|
textFieldText: underloadPacketMagicHeader
|
||||||
textField.validator: IntValidator { bottom: 0 }
|
textField.validator: IntValidator { bottom: 0 }
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== serverUnderloadPacketMagicHeader) {
|
if (textFieldText !== underloadPacketMagicHeader) {
|
||||||
serverUnderloadPacketMagicHeader = textFieldText
|
underloadPacketMagicHeader = textFieldText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,22 +356,18 @@ PageType {
|
|||||||
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
||||||
|
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
forceActiveFocus()
|
if (AwgConfigModel.isHeadersEqual(underloadPacketMagicHeaderTextField.textField.text,
|
||||||
|
transportPacketMagicHeaderTextField.textField.text,
|
||||||
|
responsePacketMagicHeaderTextField.textField.text,
|
||||||
|
initPacketMagicHeaderTextField.textField.text)) {
|
||||||
|
PageController.showErrorMessage(qsTr("The values of the H1-H4 fields must be unique"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (delegateItem.isEnabled) {
|
if (AwgConfigModel.isPacketSizeEqual(parseInt(initPacketJunkSizeTextField.textField.text),
|
||||||
if (AwgConfigModel.isHeadersEqual(underloadPacketMagicHeaderTextField.textField.text,
|
parseInt(responsePacketJunkSizeTextField.textField.text))) {
|
||||||
transportPacketMagicHeaderTextField.textField.text,
|
PageController.showErrorMessage(qsTr("The value of the field S1 + message initiation size (148) must not equal S2 + message response size (92)"))
|
||||||
responsePacketMagicHeaderTextField.textField.text,
|
return
|
||||||
initPacketMagicHeaderTextField.textField.text)) {
|
|
||||||
PageController.showErrorMessage(qsTr("The values of the H1-H4 fields must be unique"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AwgConfigModel.isPacketSizeEqual(parseInt(initPacketJunkSizeTextField.textField.text),
|
|
||||||
parseInt(responsePacketJunkSizeTextField.textField.text))) {
|
|
||||||
PageController.showErrorMessage(qsTr("The value of the field S1 + message initiation size (148) must not equal S2 + message response size (92)"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var headerText = qsTr("Save settings?")
|
var headerText = qsTr("Save settings?")
|
||||||
@@ -359,6 +376,8 @@ PageType {
|
|||||||
var noButtonText = qsTr("Cancel")
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
var yesButtonFunction = function() {
|
var yesButtonFunction = function() {
|
||||||
|
forceActiveFocus()
|
||||||
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
|
||||||
|
|
||||||
import PageEnum 1.0
|
|
||||||
|
|
||||||
import "./"
|
|
||||||
import "../Controls2"
|
|
||||||
import "../Controls2/TextTypes"
|
|
||||||
import "../Config"
|
|
||||||
import "../Components"
|
|
||||||
|
|
||||||
|
|
||||||
PageType {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
defaultActiveFocusItem: listview.currentItem.mtuTextField.textField
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: focusItem
|
|
||||||
onFocusChanged: {
|
|
||||||
if (activeFocus) {
|
|
||||||
fl.ensureVisible(focusItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KeyNavigation.tab: backButton
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: backButtonLayout
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
anchors.topMargin: 20
|
|
||||||
|
|
||||||
BackButtonType {
|
|
||||||
id: backButton
|
|
||||||
KeyNavigation.tab: listview.currentItem.mtuTextField.textField
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FlickableType {
|
|
||||||
id: fl
|
|
||||||
anchors.top: backButtonLayout.bottom
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
contentHeight: content.implicitHeight + saveButton.implicitHeight + saveButton.anchors.bottomMargin + saveButton.anchors.topMargin
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: content
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: listview
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
height: listview.contentItem.height
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
interactive: false
|
|
||||||
|
|
||||||
model: WireGuardConfigModel
|
|
||||||
|
|
||||||
delegate: Item {
|
|
||||||
id: delegateItem
|
|
||||||
implicitWidth: listview.width
|
|
||||||
implicitHeight: col.implicitHeight
|
|
||||||
|
|
||||||
property alias mtuTextField: mtuTextField
|
|
||||||
property bool isSaveButtonEnabled: mtuTextField.errorText === ""
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: col
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
anchors.leftMargin: 16
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
HeaderType {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
headerText: qsTr("WG settings")
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: mtuTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 40
|
|
||||||
|
|
||||||
headerText: qsTr("MTU")
|
|
||||||
textFieldText: clientMtu
|
|
||||||
textField.validator: IntValidator { bottom: 576; top: 65535 }
|
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
|
||||||
if (textFieldText !== clientMtu) {
|
|
||||||
clientMtu = textFieldText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkEmptyText: true
|
|
||||||
KeyNavigation.tab: saveButton
|
|
||||||
}
|
|
||||||
|
|
||||||
Header2TextType {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 16
|
|
||||||
|
|
||||||
text: qsTr("Server settings")
|
|
||||||
}
|
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
|
||||||
id: portTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: 8
|
|
||||||
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
|
||||||
textFieldText: port
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BasicButtonType {
|
|
||||||
id: saveButton
|
|
||||||
|
|
||||||
anchors.right: root.right
|
|
||||||
anchors.left: root.left
|
|
||||||
anchors.bottom: root.bottom
|
|
||||||
|
|
||||||
anchors.topMargin: 24
|
|
||||||
anchors.bottomMargin: 24
|
|
||||||
anchors.rightMargin: 16
|
|
||||||
anchors.leftMargin: 16
|
|
||||||
|
|
||||||
enabled: listview.currentItem.isSaveButtonEnabled
|
|
||||||
|
|
||||||
text: qsTr("Save")
|
|
||||||
|
|
||||||
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
|
||||||
|
|
||||||
clickedFunc: function() {
|
|
||||||
forceActiveFocus()
|
|
||||||
var headerText = qsTr("Save settings?")
|
|
||||||
var descriptionText = qsTr("Only the settings for this device will be changed")
|
|
||||||
var yesButtonText = qsTr("Continue")
|
|
||||||
var noButtonText = qsTr("Cancel")
|
|
||||||
|
|
||||||
var yesButtonFunction = function() {
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
|
||||||
InstallController.updateContainer(WireGuardConfigModel.getConfig())
|
|
||||||
}
|
|
||||||
var noButtonFunction = function() {
|
|
||||||
if (!GC.isMobile()) {
|
|
||||||
saveButton.forceActiveFocus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -72,10 +72,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: delegateItem
|
|
||||||
|
|
||||||
property alias focusItemId: portTextField.textField
|
property alias focusItemId: portTextField.textField
|
||||||
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
|
||||||
|
|
||||||
implicitWidth: listview.width
|
implicitWidth: listview.width
|
||||||
implicitHeight: col.implicitHeight
|
implicitHeight: col.implicitHeight
|
||||||
@@ -102,14 +99,12 @@ PageType {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
|
|
||||||
enabled: delegateItem.isEnabled
|
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textFieldText: port
|
textFieldText: port
|
||||||
textField.maximumLength: 5
|
textField.maximumLength: 5
|
||||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||||
|
|
||||||
KeyNavigation.tab: saveButton
|
KeyNavigation.tab: mtuTextField.textField
|
||||||
|
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textFieldText !== port) {
|
if (textFieldText !== port) {
|
||||||
@@ -120,41 +115,52 @@ PageType {
|
|||||||
checkEmptyText: true
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextFieldWithHeaderType {
|
||||||
|
id: mtuTextField
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
|
|
||||||
|
headerText: qsTr("MTU")
|
||||||
|
textFieldText: mtu
|
||||||
|
textField.validator: IntValidator { bottom: 576; top: 65535 }
|
||||||
|
|
||||||
|
KeyNavigation.tab: saveButton
|
||||||
|
|
||||||
|
textField.onEditingFinished: {
|
||||||
|
if (textFieldText === "") {
|
||||||
|
textFieldText = "0"
|
||||||
|
}
|
||||||
|
if (textFieldText !== mtu) {
|
||||||
|
mtu = textFieldText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkEmptyText: true
|
||||||
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
id: saveButton
|
id: saveButton
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.bottomMargin: 24
|
Layout.bottomMargin: 24
|
||||||
|
|
||||||
enabled: portTextField.errorText === ""
|
enabled: mtuTextField.errorText === "" &&
|
||||||
|
portTextField.errorText === ""
|
||||||
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
|
|
||||||
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
||||||
|
|
||||||
onClicked: function() {
|
onClicked: {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
|
|
||||||
var headerText = qsTr("Save settings?")
|
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
||||||
var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
|
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
||||||
var yesButtonText = qsTr("Continue")
|
return
|
||||||
var noButtonText = qsTr("Cancel")
|
|
||||||
|
|
||||||
var yesButtonFunction = function() {
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
|
||||||
InstallController.updateContainer(WireGuardConfigModel.getConfig())
|
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {
|
|
||||||
if (!GC.isMobile()) {
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
saveRestartButton.forceActiveFocus()
|
InstallController.updateContainer(WireGuardConfigModel.getConfig())
|
||||||
}
|
focusItem.forceActiveFocus()
|
||||||
}
|
|
||||||
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: saveButton.clicked()
|
Keys.onEnterPressed: saveButton.clicked()
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
property var focusItem: clientSettings.rightButton
|
property var focusItem: button.rightButton
|
||||||
|
|
||||||
implicitWidth: protocols.width
|
implicitWidth: protocols.width
|
||||||
implicitHeight: delegateContent.implicitHeight
|
implicitHeight: delegateContent.implicitHeight
|
||||||
@@ -89,49 +89,13 @@ PageType {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
property bool isClientSettingsVisible: protocolIndex === ProtocolEnum.WireGuard || protocolIndex === ProtocolEnum.Awg
|
|
||||||
property bool isServerSettingsVisible: ServersModel.isProcessedServerHasWriteAccess()
|
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
id: clientSettings
|
id: button
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: protocolName + qsTr(" connection settings")
|
text: protocolName
|
||||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||||
visible: delegateContent.isClientSettingsVisible
|
|
||||||
|
|
||||||
clickedFunction: function() {
|
|
||||||
if (isClientProtocolExists) {
|
|
||||||
switch (protocolIndex) {
|
|
||||||
case ProtocolEnum.WireGuard: WireGuardConfigModel.updateModel(ProtocolsModel.getConfig()); break;
|
|
||||||
case ProtocolEnum.Awg: AwgConfigModel.updateModel(ProtocolsModel.getConfig()); break;
|
|
||||||
}
|
|
||||||
PageController.goToPage(clientProtocolPage);
|
|
||||||
} else {
|
|
||||||
PageController.showNotificationMessage(qsTr("Click the \"connect\" button to create a connection configuration"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: clientSettings
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DividerType {
|
|
||||||
visible: delegateContent.isClientSettingsVisible
|
|
||||||
}
|
|
||||||
|
|
||||||
LabelWithButtonType {
|
|
||||||
id: serverSettings
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
text: protocolName + qsTr(" server settings")
|
|
||||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
|
||||||
visible: delegateContent.isServerSettingsVisible
|
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
switch (protocolIndex) {
|
switch (protocolIndex) {
|
||||||
@@ -145,19 +109,17 @@ PageType {
|
|||||||
case ProtocolEnum.Ipsec: Ikev2ConfigModel.updateModel(ProtocolsModel.getConfig()); break;
|
case ProtocolEnum.Ipsec: Ikev2ConfigModel.updateModel(ProtocolsModel.getConfig()); break;
|
||||||
case ProtocolEnum.Socks5Proxy: Socks5ProxyConfigModel.updateModel(ProtocolsModel.getConfig()); break;
|
case ProtocolEnum.Socks5Proxy: Socks5ProxyConfigModel.updateModel(ProtocolsModel.getConfig()); break;
|
||||||
}
|
}
|
||||||
PageController.goToPage(serverProtocolPage);
|
PageController.goToPage(protocolPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: serverSettings
|
anchors.fill: button
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
enabled: false
|
enabled: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {}
|
||||||
visible: delegateContent.isServerSettingsVisible
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,11 +132,11 @@ PageType {
|
|||||||
visible: root.isClearCacheVisible
|
visible: root.isClearCacheVisible
|
||||||
KeyNavigation.tab: removeButton
|
KeyNavigation.tab: removeButton
|
||||||
|
|
||||||
text: qsTr("Clear profile")
|
text: qsTr("Clear %1 profile").arg(ContainersModel.getProcessedContainerName())
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
var headerText = qsTr("Clear %1 profile?").arg(ContainersModel.getProcessedContainerName())
|
var headerText = qsTr("Clear %1 profile?").arg(ContainersModel.getProcessedContainerName())
|
||||||
var descriptionText = qsTr("The connection configuration will be deleted for this device only")
|
var descriptionText = qsTr("")
|
||||||
var yesButtonText = qsTr("Continue")
|
var yesButtonText = qsTr("Continue")
|
||||||
var noButtonText = qsTr("Cancel")
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
@@ -221,7 +183,7 @@ PageType {
|
|||||||
visible: ServersModel.isProcessedServerHasWriteAccess()
|
visible: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
||||||
|
|
||||||
text: qsTr("Remove ")
|
text: qsTr("Remove ") + ContainersModel.getProcessedContainerName()
|
||||||
textColor: AmneziaStyle.color.vibrantRed
|
textColor: AmneziaStyle.color.vibrantRed
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
|
|||||||
@@ -211,6 +211,25 @@ QString Utils::tun2socksPath()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Utils::logException(const std::exception &e)
|
||||||
|
{
|
||||||
|
qCritical() << e.what();
|
||||||
|
try {
|
||||||
|
std::rethrow_if_nested(e);
|
||||||
|
} catch (const std::exception &nested) {
|
||||||
|
logException(nested);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Utils::logException(const std::exception_ptr &eptr)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (eptr) std::rethrow_exception(eptr);
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
logException(e);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Inspired from http://stackoverflow.com/a/15281070/1529139
|
// Inspired from http://stackoverflow.com/a/15281070/1529139
|
||||||
// and http://stackoverflow.com/q/40059902/1529139
|
// and http://stackoverflow.com/q/40059902/1529139
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ public:
|
|||||||
static QString certUtilPath();
|
static QString certUtilPath();
|
||||||
static QString tun2socksPath();
|
static QString tun2socksPath();
|
||||||
|
|
||||||
|
static void logException(const std::exception &e);
|
||||||
|
static void logException(const std::exception_ptr &eptr = std::current_exception());
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+28
-61
@@ -1,16 +1,16 @@
|
|||||||
#include "qtimer.h"
|
#include "qtimer.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEventLoop>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
#include "core/controllers/serverController.h"
|
|
||||||
#include <configurators/cloak_configurator.h>
|
#include <configurators/cloak_configurator.h>
|
||||||
#include <configurators/openvpn_configurator.h>
|
#include <configurators/openvpn_configurator.h>
|
||||||
#include <configurators/shadowsocks_configurator.h>
|
#include <configurators/shadowsocks_configurator.h>
|
||||||
#include <configurators/wireguard_configurator.h>
|
#include <configurators/wireguard_configurator.h>
|
||||||
|
#include "core/controllers/serverController.h"
|
||||||
|
|
||||||
#ifdef AMNEZIA_DESKTOP
|
#ifdef AMNEZIA_DESKTOP
|
||||||
#include "core/ipcclient.h"
|
#include "core/ipcclient.h"
|
||||||
@@ -34,7 +34,8 @@ VpnConnection::VpnConnection(std::shared_ptr<Settings> settings, QObject *parent
|
|||||||
{
|
{
|
||||||
m_checkTimer.setInterval(1000);
|
m_checkTimer.setInterval(1000);
|
||||||
#ifdef Q_OS_IOS
|
#ifdef Q_OS_IOS
|
||||||
connect(IosController::Instance(), &IosController::connectionStateChanged, this, &VpnConnection::onConnectionStateChanged);
|
connect(IosController::Instance(), &IosController::connectionStateChanged, this,
|
||||||
|
&VpnConnection::onConnectionStateChanged);
|
||||||
connect(IosController::Instance(), &IosController::bytesChanged, this, &VpnConnection::onBytesChanged);
|
connect(IosController::Instance(), &IosController::bytesChanged, this, &VpnConnection::onBytesChanged);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -57,7 +58,7 @@ void VpnConnection::onConnectionStateChanged(Vpn::ConnectionState state)
|
|||||||
|
|
||||||
#ifdef AMNEZIA_DESKTOP
|
#ifdef AMNEZIA_DESKTOP
|
||||||
QString proto = m_settings->defaultContainerName(m_settings->defaultServerIndex());
|
QString proto = m_settings->defaultContainerName(m_settings->defaultServerIndex());
|
||||||
|
|
||||||
if (IpcClient::Interface()) {
|
if (IpcClient::Interface()) {
|
||||||
if (state == Vpn::ConnectionState::Connected) {
|
if (state == Vpn::ConnectionState::Connected) {
|
||||||
IpcClient::Interface()->resetIpStack();
|
IpcClient::Interface()->resetIpStack();
|
||||||
@@ -71,7 +72,7 @@ void VpnConnection::onConnectionStateChanged(Vpn::ConnectionState state)
|
|||||||
|
|
||||||
if (m_settings->isSitesSplitTunnelingEnabled()) {
|
if (m_settings->isSitesSplitTunnelingEnabled()) {
|
||||||
IpcClient::Interface()->routeDeleteList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0");
|
IpcClient::Interface()->routeDeleteList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0");
|
||||||
// qDebug() << "VpnConnection::onConnectionStateChanged :: adding custom routes, count:" << forwardIps.size();
|
// qDebug() << "VpnConnection::onConnectionStateChanged :: adding custom routes, count:" << forwardIps.size();
|
||||||
if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) {
|
if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) {
|
||||||
QTimer::singleShot(1000, m_vpnProtocol.data(),
|
QTimer::singleShot(1000, m_vpnProtocol.data(),
|
||||||
[this]() { addSitesRoutes(m_vpnProtocol->vpnGateway(), m_settings->routeMode()); });
|
[this]() { addSitesRoutes(m_vpnProtocol->vpnGateway(), m_settings->routeMode()); });
|
||||||
@@ -290,62 +291,27 @@ void VpnConnection::appendKillSwitchConfig()
|
|||||||
|
|
||||||
void VpnConnection::appendSplitTunnelingConfig()
|
void VpnConnection::appendSplitTunnelingConfig()
|
||||||
{
|
{
|
||||||
bool allowSiteBasedSplitTunneling = true;
|
if (m_vpnConfiguration.value(config_key::configVersion).toInt()) {
|
||||||
|
auto protocolName = m_vpnConfiguration.value(config_key::vpnproto).toString();
|
||||||
|
if (protocolName == ProtocolProps::protoToString(Proto::Awg)) {
|
||||||
|
auto configData = m_vpnConfiguration.value(protocolName + "_config_data").toObject();
|
||||||
|
QJsonArray allowedIpsJsonArray = QJsonArray::fromStringList(configData.value("allowed_ips").toString().split(","));
|
||||||
|
QJsonArray defaultAllowedIP = QJsonArray::fromStringList(QString("0.0.0.0/0, ::/0").split(","));
|
||||||
|
|
||||||
// this block is for old native configs and for old self-hosted configs
|
if (allowedIpsJsonArray != defaultAllowedIP) {
|
||||||
auto protocolName = m_vpnConfiguration.value(config_key::vpnproto).toString();
|
allowedIpsJsonArray.append(m_vpnConfiguration.value(config_key::dns1).toString());
|
||||||
if (protocolName == ProtocolProps::protoToString(Proto::Awg) || protocolName == ProtocolProps::protoToString(Proto::WireGuard)) {
|
allowedIpsJsonArray.append(m_vpnConfiguration.value(config_key::dns2).toString());
|
||||||
allowSiteBasedSplitTunneling = false;
|
|
||||||
auto configData = m_vpnConfiguration.value(protocolName + "_config_data").toObject();
|
m_vpnConfiguration.insert(config_key::splitTunnelType, Settings::RouteMode::VpnOnlyForwardSites);
|
||||||
if (configData.value(config_key::allowed_ips).isString()) {
|
m_vpnConfiguration.insert(config_key::splitTunnelSites, allowedIpsJsonArray);
|
||||||
QJsonArray allowedIpsJsonArray = QJsonArray::fromStringList(configData.value(config_key::allowed_ips).toString().split(", "));
|
|
||||||
configData.insert(config_key::allowed_ips, allowedIpsJsonArray);
|
|
||||||
m_vpnConfiguration.insert(protocolName + "_config_data", configData);
|
|
||||||
} else if (configData.value(config_key::allowed_ips).isUndefined()) {
|
|
||||||
auto nativeConfig = configData.value(config_key::config).toString();
|
|
||||||
auto nativeConfigLines = nativeConfig.split("\n");
|
|
||||||
for (auto &line : nativeConfigLines) {
|
|
||||||
if (line.contains("AllowedIPs")) {
|
|
||||||
auto allowedIpsString = line.split(" = ");
|
|
||||||
if (allowedIpsString.size() < 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QJsonArray allowedIpsJsonArray = QJsonArray::fromStringList(allowedIpsString.at(1).split(", "));
|
|
||||||
configData.insert(config_key::allowed_ips, allowedIpsJsonArray);
|
|
||||||
m_vpnConfiguration.insert(protocolName + "_config_data", configData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Settings::RouteMode routeMode = Settings::RouteMode::VpnAllSites;
|
||||||
|
QJsonArray sitesJsonArray;
|
||||||
|
if (m_settings->isSitesSplitTunnelingEnabled()) {
|
||||||
|
routeMode = m_settings->routeMode();
|
||||||
|
|
||||||
if (configData.value(config_key::persistent_keep_alive).isUndefined()) {
|
|
||||||
auto nativeConfig = configData.value(config_key::config).toString();
|
|
||||||
auto nativeConfigLines = nativeConfig.split("\n");
|
|
||||||
for (auto &line : nativeConfigLines) {
|
|
||||||
if (line.contains("PersistentKeepalive")) {
|
|
||||||
auto persistentKeepaliveString = line.split(" = ");
|
|
||||||
if (persistentKeepaliveString.size() < 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
configData.insert(config_key::persistent_keep_alive, persistentKeepaliveString.at(1));
|
|
||||||
m_vpnConfiguration.insert(protocolName + "_config_data", configData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonArray allowedIpsJsonArray = configData.value(config_key::allowed_ips).toArray();
|
|
||||||
if (allowedIpsJsonArray.contains("0.0.0.0/0") && allowedIpsJsonArray.contains("::/0")) {
|
|
||||||
allowSiteBasedSplitTunneling = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Settings::RouteMode routeMode = Settings::RouteMode::VpnAllSites;
|
|
||||||
QJsonArray sitesJsonArray;
|
|
||||||
if (m_settings->isSitesSplitTunnelingEnabled()) {
|
|
||||||
routeMode = m_settings->routeMode();
|
|
||||||
|
|
||||||
if (allowSiteBasedSplitTunneling) {
|
|
||||||
auto sites = m_settings->getVpnIps(routeMode);
|
auto sites = m_settings->getVpnIps(routeMode);
|
||||||
for (const auto &site : sites) {
|
for (const auto &site : sites) {
|
||||||
sitesJsonArray.append(site);
|
sitesJsonArray.append(site);
|
||||||
@@ -357,10 +323,10 @@ void VpnConnection::appendSplitTunnelingConfig()
|
|||||||
sitesJsonArray.append(m_vpnConfiguration.value(config_key::dns2).toString());
|
sitesJsonArray.append(m_vpnConfiguration.value(config_key::dns2).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_vpnConfiguration.insert(config_key::splitTunnelType, routeMode);
|
m_vpnConfiguration.insert(config_key::splitTunnelType, routeMode);
|
||||||
m_vpnConfiguration.insert(config_key::splitTunnelSites, sitesJsonArray);
|
m_vpnConfiguration.insert(config_key::splitTunnelSites, sitesJsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
Settings::AppsRouteMode appsRouteMode = Settings::AppsRouteMode::VpnAllApps;
|
Settings::AppsRouteMode appsRouteMode = Settings::AppsRouteMode::VpnAllApps;
|
||||||
QJsonArray appsJsonArray;
|
QJsonArray appsJsonArray;
|
||||||
@@ -393,7 +359,8 @@ void VpnConnection::createAndroidConnections()
|
|||||||
|
|
||||||
connect(AndroidController::instance(), &AndroidController::connectionStateChanged, androidVpnProtocol,
|
connect(AndroidController::instance(), &AndroidController::connectionStateChanged, androidVpnProtocol,
|
||||||
&AndroidVpnProtocol::setConnectionState);
|
&AndroidVpnProtocol::setConnectionState);
|
||||||
connect(AndroidController::instance(), &AndroidController::statisticsUpdated, androidVpnProtocol, &AndroidVpnProtocol::setBytesChanged);
|
connect(AndroidController::instance(), &AndroidController::statisticsUpdated, androidVpnProtocol,
|
||||||
|
&AndroidVpnProtocol::setBytesChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidVpnProtocol *VpnConnection::createDefaultAndroidVpnProtocol()
|
AndroidVpnProtocol *VpnConnection::createDefaultAndroidVpnProtocol()
|
||||||
|
|||||||
+2
-2
@@ -235,7 +235,7 @@ bool IpcServer::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterInd
|
|||||||
LinuxFirewall::updateBlockNets(blocknets);
|
LinuxFirewall::updateBlockNets(blocknets);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("200.allowVPN"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("200.allowVPN"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv6, QStringLiteral("250.blockIPv6"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv6, QStringLiteral("250.blockIPv6"), true);
|
||||||
// LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("290.allowDHCP"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("290.allowDHCP"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("300.allowLAN"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("300.allowLAN"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("310.blockDNS"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("310.blockDNS"), true);
|
||||||
QStringList dnsServers;
|
QStringList dnsServers;
|
||||||
@@ -265,7 +265,7 @@ bool IpcServer::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterInd
|
|||||||
MacOSFirewall::setAnchorTable(QStringLiteral("120.blockNets"), blockNets, QStringLiteral("blocknets"), blocknets);
|
MacOSFirewall::setAnchorTable(QStringLiteral("120.blockNets"), blockNets, QStringLiteral("blocknets"), blocknets);
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("200.allowVPN"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("200.allowVPN"), true);
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("250.blockIPv6"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("250.blockIPv6"), true);
|
||||||
// MacOSFirewall::setAnchorEnabled(QStringLiteral("290.allowDHCP"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("290.allowDHCP"), true);
|
||||||
MacOSFirewall::setAnchorEnabled(QStringLiteral("300.allowLAN"), true);
|
MacOSFirewall::setAnchorEnabled(QStringLiteral("300.allowLAN"), true);
|
||||||
|
|
||||||
QStringList dnsServers;
|
QStringList dnsServers;
|
||||||
|
|||||||
Reference in New Issue
Block a user