mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-07-03 14:07:39 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbcf928a66 | |||
| a32952fde6 | |||
| 9c4ee4014d | |||
| e402cacc05 | |||
| a98cd248d6 | |||
| 00fbfb6a01 | |||
| 86c31c3766 |
@@ -175,7 +175,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
return
|
||||
}
|
||||
|
||||
guard let wgConfigStr = try? JSONDecoder().decode(WGConfig.self, from: wgConfig).wg,
|
||||
guard let wgConfigStr = try? JSONDecoder().decode(WGConfig.self, from: wgConfig).str,
|
||||
let tunnelConfiguration = try? TunnelConfiguration(fromWgQuickConfig: wgConfigStr)
|
||||
else {
|
||||
wg_log(.error, message: "Can't parse WireGuard config")
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import Foundation
|
||||
|
||||
struct WGConfigData: Decodable {
|
||||
let h1, h2, h3, h4: String?
|
||||
let jc, jmax, jmin: String?
|
||||
let s1, s2: String?
|
||||
let initPacketMagicHeader, responsePacketMagicHeader: String?
|
||||
let underloadPacketMagicHeader, transportPacketMagicHeader: String?
|
||||
let junkPacketCount, junkPacketMinSize, junkPacketMaxSize: String?
|
||||
let initPacketJunkSize, responsePacketJunkSize: String?
|
||||
|
||||
var settings: String {
|
||||
jc == nil ? "" :
|
||||
junkPacketCount == nil ? "" :
|
||||
"""
|
||||
Jc = \(jc!)
|
||||
Jmin = \(jmin!)
|
||||
Jmax = \(jmax!)
|
||||
S1 = \(s1!)
|
||||
S2 = \(s2!)
|
||||
H1 = \(h1!)
|
||||
H2 = \(h2!)
|
||||
H3 = \(h3!)
|
||||
H4 = \(h4!)
|
||||
Jc = \(junkPacketCount!)
|
||||
Jmin = \(junkPacketMinSize!)
|
||||
Jmax = \(junkPacketMaxSize!)
|
||||
S1 = \(initPacketJunkSize!)
|
||||
S2 = \(responsePacketJunkSize!)
|
||||
H1 = \(initPacketMagicHeader!)
|
||||
H2 = \(responsePacketMagicHeader!)
|
||||
H3 = \(underloadPacketMagicHeader!)
|
||||
H4 = \(transportPacketMagicHeader!)
|
||||
|
||||
"""
|
||||
}
|
||||
@@ -33,9 +34,10 @@ struct WGConfigData: Decodable {
|
||||
var persistentKeepAlive: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case h1 = "H1", h2 = "H2", h3 = "H3", h4 = "H4"
|
||||
case jc = "Jc", jmax = "Jmax", jmin = "Jmin"
|
||||
case s1 = "S1", s2 = "S2"
|
||||
case initPacketMagicHeader = "H1", responsePacketMagicHeader = "H2"
|
||||
case underloadPacketMagicHeader = "H3", transportPacketMagicHeader = "H4"
|
||||
case junkPacketCount = "Jc", junkPacketMinSize = "Jmin", junkPacketMaxSize = "Jmax"
|
||||
case initPacketJunkSize = "S1", responsePacketJunkSize = "S2"
|
||||
|
||||
case clientIP = "client_ip" // "10.8.1.16"
|
||||
case clientPrivateKey = "client_priv_key"
|
||||
@@ -51,15 +53,15 @@ struct WGConfigData: Decodable {
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.h1 = try container.decodeIfPresent(String.self, forKey: .h1)
|
||||
self.h2 = try container.decodeIfPresent(String.self, forKey: .h2)
|
||||
self.h3 = try container.decodeIfPresent(String.self, forKey: .h3)
|
||||
self.h4 = try container.decodeIfPresent(String.self, forKey: .h4)
|
||||
self.jc = try container.decodeIfPresent(String.self, forKey: .jc)
|
||||
self.jmax = try container.decodeIfPresent(String.self, forKey: .jmax)
|
||||
self.jmin = try container.decodeIfPresent(String.self, forKey: .jmin)
|
||||
self.s1 = try container.decodeIfPresent(String.self, forKey: .s1)
|
||||
self.s2 = try container.decodeIfPresent(String.self, forKey: .s2)
|
||||
self.initPacketMagicHeader = try container.decodeIfPresent(String.self, forKey: .initPacketMagicHeader)
|
||||
self.responsePacketMagicHeader = try container.decodeIfPresent(String.self, forKey: .responsePacketMagicHeader)
|
||||
self.underloadPacketMagicHeader = try container.decodeIfPresent(String.self, forKey: .underloadPacketMagicHeader)
|
||||
self.transportPacketMagicHeader = try container.decodeIfPresent(String.self, forKey: .transportPacketMagicHeader)
|
||||
self.junkPacketCount = try container.decodeIfPresent(String.self, forKey: .junkPacketCount)
|
||||
self.junkPacketMinSize = try container.decodeIfPresent(String.self, forKey: .junkPacketMinSize)
|
||||
self.junkPacketMaxSize = try container.decodeIfPresent(String.self, forKey: .junkPacketMaxSize)
|
||||
self.initPacketJunkSize = try container.decodeIfPresent(String.self, forKey: .initPacketJunkSize)
|
||||
self.responsePacketJunkSize = try container.decodeIfPresent(String.self, forKey: .responsePacketJunkSize)
|
||||
self.clientIP = try container.decode(String.self, forKey: .clientIP)
|
||||
self.clientPrivateKey = try container.decode(String.self, forKey: .clientPrivateKey)
|
||||
self.clientPublicKey = try container.decode(String.self, forKey: .clientPublicKey)
|
||||
@@ -115,7 +117,7 @@ struct WGConfig: Decodable {
|
||||
self.splitTunnelType = try container.decode(Int.self, forKey: .splitTunnelType)
|
||||
}
|
||||
|
||||
var wg: String {
|
||||
var str: String {
|
||||
"""
|
||||
[Interface]
|
||||
Address = \(data.clientIP)/32
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1374
-1083
File diff suppressed because it is too large
Load Diff
+1277
-1045
File diff suppressed because it is too large
Load Diff
+1410
-1008
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,14 @@ DrawerType2 {
|
||||
expandedContent: Item {
|
||||
implicitHeight: root.expandedHeight
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
|
||||
function onOpened() {
|
||||
header.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
Header2Type {
|
||||
id: header
|
||||
anchors.top: parent.top
|
||||
@@ -48,6 +56,8 @@ DrawerType2 {
|
||||
anchors.rightMargin: 16
|
||||
|
||||
headerText: root.headerText
|
||||
|
||||
KeyNavigation.tab: shareButton
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
@@ -68,12 +78,15 @@ DrawerType2 {
|
||||
visible: root.contentVisible
|
||||
|
||||
BasicButtonType {
|
||||
id: shareButton
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
|
||||
text: qsTr("Share")
|
||||
imageSource: "qrc:/images/controls/share-2.svg"
|
||||
|
||||
KeyNavigation.tab: copyConfigTextButton
|
||||
|
||||
clickedFunc: function() {
|
||||
var fileName = ""
|
||||
if (GC.isMobile()) {
|
||||
@@ -108,12 +121,7 @@ DrawerType2 {
|
||||
text: qsTr("Copy")
|
||||
imageSource: "qrc:/images/controls/copy.svg"
|
||||
|
||||
clickedFunc: function() {
|
||||
configText.selectAll()
|
||||
configText.copy()
|
||||
configText.select(0, 0)
|
||||
PageController.showNotificationMessage(qsTr("Copied"))
|
||||
}
|
||||
KeyNavigation.tab: copyNativeConfigStringButton.visible ? copyNativeConfigStringButton : showSettingsButton
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
@@ -133,15 +141,12 @@ DrawerType2 {
|
||||
text: qsTr("Copy config string")
|
||||
imageSource: "qrc:/images/controls/copy.svg"
|
||||
|
||||
clickedFunc: function() {
|
||||
nativeConfigString.selectAll()
|
||||
nativeConfigString.copy()
|
||||
nativeConfigString.select(0, 0)
|
||||
PageController.showNotificationMessage(qsTr("Copied"))
|
||||
}
|
||||
KeyNavigation.tab: showSettingsButton
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
id: showSettingsButton
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
|
||||
@@ -157,6 +162,8 @@ DrawerType2 {
|
||||
clickedFunc: function() {
|
||||
configContentDrawer.open()
|
||||
}
|
||||
|
||||
KeyNavigation.tab: header
|
||||
}
|
||||
|
||||
DrawerType2 {
|
||||
|
||||
@@ -31,22 +31,23 @@ Button {
|
||||
hoverEnabled: true
|
||||
|
||||
background: Rectangle {
|
||||
id: background_border
|
||||
id: focusBorder
|
||||
|
||||
color: "transparent"
|
||||
border.color: root.activeFocus ? root.borderFocusedColor : "transparent"
|
||||
border.width: root.activeFocus ? root.borderFocusedWidth : "transparent"
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
radius: 16
|
||||
|
||||
Rectangle {
|
||||
id: background
|
||||
|
||||
anchors.fill: background_border
|
||||
anchors.margins: root.activeFocus ? 2: 0
|
||||
anchors.fill: focusBorder
|
||||
anchors.margins: root.activeFocus ? 2 : 0
|
||||
|
||||
radius: 16
|
||||
radius: root.activeFocus ? 14 : 16
|
||||
color: {
|
||||
if (root.enabled) {
|
||||
if (root.pressed) {
|
||||
@@ -57,8 +58,8 @@ Button {
|
||||
return disabledColor
|
||||
}
|
||||
}
|
||||
border.color: root.activeFocus ? "transparent" : borderColor
|
||||
border.width: root.activeFocus ? 0 : borderWidth
|
||||
border.color: borderColor
|
||||
border.width: borderWidth
|
||||
|
||||
Behavior on color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
@@ -93,13 +94,13 @@ Button {
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: background_border
|
||||
anchors.fill: focusBorder
|
||||
enabled: false
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
anchors.fill: background_border
|
||||
anchors.fill: focusBorder
|
||||
|
||||
implicitWidth: content.implicitWidth
|
||||
implicitHeight: content.implicitHeight
|
||||
|
||||
@@ -74,6 +74,8 @@ Item {
|
||||
enabled: root.textFieldEditable
|
||||
color: root.enabled ? root.textFieldTextColor : root.textFieldTextDisabledColor
|
||||
|
||||
inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhSensitiveData | Qt.ImhNoPredictiveText
|
||||
|
||||
placeholderText: root.textFieldPlaceholderText
|
||||
placeholderTextColor: "#494B50"
|
||||
|
||||
|
||||
@@ -213,6 +213,9 @@ PageType {
|
||||
model: SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
sorters: [
|
||||
RoleSorter { roleName: "isInstalled"; sortOrder: Qt.DescendingOrder }
|
||||
]
|
||||
}
|
||||
|
||||
Component.onCompleted: updateContainersModelFilters()
|
||||
|
||||
@@ -55,6 +55,9 @@ PageType {
|
||||
model: SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
sorters: [
|
||||
RoleSorter { roleName: "isInstalled"; sortOrder: Qt.DescendingOrder }
|
||||
]
|
||||
}
|
||||
|
||||
Component.onCompleted: updateContainersModelFilters()
|
||||
|
||||
Reference in New Issue
Block a user