Files
amnezia-client/client/ui/qml/Pages2/PageProtocolAwgClientSettings.qml
T

452 lines
13 KiB
QML
Raw Normal View History

2024-09-13 12:38:48 +04:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
2024-09-13 12:38:48 +04:00
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
BackButtonType {
id: backButton
2024-09-13 12:38:48 +04:00
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20 + PageController.safeAreaTopMargin
2024-09-13 12:38:48 +04:00
onActiveFocusChanged: {
if(backButton.enabled && backButton.activeFocus) {
listView.positionViewAtBeginning()
}
2024-09-13 12:38:48 +04:00
}
}
SmartScroll {
id: smartScroll
listView: listView
}
ListViewType {
id: listView
2024-12-31 04:16:52 +01:00
anchors.top: backButton.bottom
2024-12-31 04:16:52 +01:00
anchors.bottom: saveButton.top
anchors.right: parent.right
anchors.left: parent.left
2024-09-13 12:38:48 +04:00
header: ColumnLayout {
width: listView.width
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
headerText: qsTr("AmneziaWG settings")
}
2024-12-31 04:16:52 +01:00
}
2024-09-13 12:38:48 +04:00
2024-12-31 04:16:52 +01:00
model: AwgConfigModel
2024-09-13 12:38:48 +04:00
delegate: ColumnLayout {
width: listView.width
2024-09-13 12:38:48 +04:00
2024-12-31 04:16:52 +01:00
property bool isSaveButtonEnabled: mtuTextField.errorText === "" &&
junkPacketMaxSizeTextField.errorText === "" &&
junkPacketMinSizeTextField.errorText === "" &&
junkPacketCountTextField.errorText === ""
2024-09-13 12:38:48 +04:00
spacing: 0
2024-09-13 12:38:48 +04:00
TextFieldWithHeaderType {
id: mtuTextField
2024-09-13 12:38:48 +04:00
Layout.fillWidth: true
Layout.topMargin: 40
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
headerText: qsTr("MTU")
textField.text: clientMtu
textField.validator: IntValidator { bottom: 576; top: 65535 }
2024-09-13 12:38:48 +04:00
textField.onEditingFinished: {
if (textField.text !== clientMtu) {
clientMtu = textField.text
}
2024-12-31 04:16:52 +01:00
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(mtuTextField)
}
}
checkEmptyText: true
}
AwgTextField {
id: junkPacketCountTextField
2024-09-13 12:38:48 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
headerText: "Jc - Junk packet count"
textField.text: clientJunkPacketCount
2024-09-13 12:38:48 +04:00
textField.onEditingFinished: {
if (textField.text !== clientJunkPacketCount) {
clientJunkPacketCount = textField.text
2024-12-31 04:16:52 +01:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(junkPacketCountTextField)
}
}
}
2024-09-13 12:38:48 +04:00
AwgTextField {
id: junkPacketMinSizeTextField
2024-09-13 12:38:48 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
headerText: "Jmin - Junk packet minimum size"
textField.text: clientJunkPacketMinSize
2024-09-13 12:38:48 +04:00
textField.onEditingFinished: {
if (textField.text !== clientJunkPacketMinSize) {
clientJunkPacketMinSize = textField.text
2024-12-31 04:16:52 +01:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(junkPacketMinSizeTextField)
}
}
}
AwgTextField {
id: junkPacketMaxSizeTextField
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
headerText: "Jmax - Junk packet maximum size"
textField.text: clientJunkPacketMaxSize
2024-09-13 12:38:48 +04:00
textField.onEditingFinished: {
if (textField.text !== clientJunkPacketMaxSize) {
clientJunkPacketMaxSize = textField.text
2024-12-31 04:16:52 +01:00
}
2025-07-07 12:03:25 +08:00
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(junkPacketMaxSizeTextField)
}
}
}
AwgTextField {
id: specialJunk1TextField
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
headerText: qsTr("I1 - First special junk packet")
textField.text: clientSpecialJunk1
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientSpecialJunk1) {
clientSpecialJunk1 = textField.text
2025-07-07 12:03:25 +08:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(specialJunk1TextField)
}
}
}
AwgTextField {
id: specialJunk2TextField
2025-07-07 12:03:25 +08:00
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("I2 - Second special junk packet")
textField.text: clientSpecialJunk2
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientSpecialJunk2) {
clientSpecialJunk2 = textField.text
2025-07-07 12:03:25 +08:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(specialJunk2TextField)
}
}
}
2025-07-07 12:03:25 +08:00
AwgTextField {
id: specialJunk3TextField
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("I3 - Third special junk packet")
textField.text: clientSpecialJunk3
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientSpecialJunk3) {
clientSpecialJunk3 = textField.text
2025-07-07 12:03:25 +08:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(specialJunk3TextField)
}
}
}
AwgTextField {
id: specialJunk4TextField
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("I4 - Fourth special junk packet")
textField.text: clientSpecialJunk4
textField.validator: null
checkEmptyText: false
2025-07-07 12:03:25 +08:00
textField.onEditingFinished: {
if (textField.text !== clientSpecialJunk4) {
clientSpecialJunk4 = textField.text
2025-07-07 12:03:25 +08:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(specialJunk4TextField)
}
}
}
AwgTextField {
id: specialJunk5TextField
Layout.leftMargin: 16
Layout.rightMargin: 16
2025-07-07 12:03:25 +08:00
headerText: qsTr("I5 - Fifth special junk packet")
textField.text: clientSpecialJunk5
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientSpecialJunk5 ) {
clientSpecialJunk5 = textField.text
2025-07-07 12:03:25 +08:00
}
}
textField.onActiveFocusChanged: {
if (textField.activeFocus) {
smartScroll.scrollToItem(specialJunk5TextField)
}
}
}
2024-12-31 04:16:52 +01:00
Header2TextType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
text: qsTr("Server settings")
}
2024-09-13 12:38:48 +04:00
AwgTextField {
id: portTextField
2024-09-13 12:38:48 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
enabled: false
2024-09-13 12:38:48 +04:00
headerText: qsTr("Port")
textField.text: port
}
2024-09-13 12:38:48 +04:00
AwgTextField {
id: initPacketJunkSizeTextField
2024-09-13 12:38:48 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
enabled: false
2025-07-07 12:03:25 +08:00
headerText: "S1 - Init packet junk size"
textField.text: serverInitPacketJunkSize
}
2025-07-07 12:03:25 +08:00
AwgTextField {
id: responsePacketJunkSizeTextField
2024-09-13 12:38:48 +04:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2025-07-07 12:03:25 +08:00
enabled: false
2024-09-13 12:38:48 +04:00
headerText: "S2 - Response packet junk size"
textField.text: serverResponsePacketJunkSize
}
2024-09-13 12:38:48 +04:00
2025-12-11 15:18:36 +08:00
AwgTextField {
id: cookieReplyPacketJunkSizeTextField
2024-09-13 12:38:48 +04:00
2026-02-26 21:12:58 +07:00
visible: isAwg2
2025-12-11 15:18:36 +08:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2024-09-13 12:38:48 +04:00
2025-12-11 15:18:36 +08:00
enabled: false
2024-09-13 12:38:48 +04:00
2025-12-11 15:18:36 +08:00
headerText: "S3 - Cookie Reply packet junk size"
textField.text: serverCookieReplyPacketJunkSize
}
2024-09-13 12:38:48 +04:00
2025-12-11 15:18:36 +08:00
AwgTextField {
id: transportPacketJunkSizeTextField
2024-12-31 04:16:52 +01:00
2026-02-26 21:12:58 +07:00
visible: isAwg2
2025-12-11 15:18:36 +08:00
Layout.leftMargin: 16
Layout.rightMargin: 16
2025-12-11 15:18:36 +08:00
enabled: false
2025-12-11 15:18:36 +08:00
headerText: "S4 - Transport packet junk size"
textField.text: serverTransportPacketJunkSize
}
AwgTextField {
id: initPacketMagicHeaderTextField
2025-07-07 12:03:25 +08:00
Layout.leftMargin: 16
Layout.rightMargin: 16
enabled: false
headerText: "H1 - Init packet magic header"
textField.text: serverInitPacketMagicHeader
}
AwgTextField {
id: responsePacketMagicHeaderTextField
Layout.leftMargin: 16
Layout.rightMargin: 16
enabled: false
headerText: "H2 - Response packet magic header"
textField.text: serverResponsePacketMagicHeader
}
AwgTextField {
id: underloadPacketMagicHeaderTextField
Layout.leftMargin: 16
Layout.rightMargin: 16
enabled: false
headerText: "H3 - Underload packet magic header"
textField.text: serverUnderloadPacketMagicHeader
}
AwgTextField {
id: transportPacketMagicHeaderTextField
Layout.leftMargin: 16
Layout.rightMargin: 16
enabled: false
headerText: "H4 - Transport packet magic header"
textField.text: serverTransportPacketMagicHeader
2024-09-13 12:38:48 +04:00
}
}
}
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
2024-09-13 12:38:48 +04:00
text: qsTr("Save")
2024-12-31 04:16:52 +01:00
onActiveFocusChanged: {
if(activeFocus) {
listView.positionViewAtEnd()
2024-12-31 04:16:52 +01:00
}
}
2024-09-13 12:38:48 +04:00
clickedFunc: function() {
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() {
2026-05-28 10:57:08 +08:00
if (ConnectionController.isConnected && ServersUiController.serverDefaultContainer(ServersUiController.defaultServerId) === ServersUiController.processedContainerIndex) {
2024-09-13 12:38:48 +04:00
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
return
}
2026-06-04 15:45:53 +01:00
InstallController.updateClientConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Awg)
2024-09-13 12:38:48 +04:00
}
var noButtonFunction = function() {}
2024-09-13 12:38:48 +04:00
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
}
}