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

458 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 "./"
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
2025-11-11 17:03:27 +03:00
anchors.topMargin: 20 + SettingsController.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
}
}
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
}
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
}
}
}
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
}
}
}
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
}
}
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
}
}
}
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
}
}
}
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
}
}
}
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
}
}
}
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
}
}
}
AwgTextField {
id: controlledJunk1TextField
2025-07-07 12:03:25 +08:00
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("J1 - First controlled junk packet")
textField.text: clientControlledJunk1
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientControlledJunk1) {
clientControlledJunk1 = textField.text
2025-07-07 12:03:25 +08:00
}
}
}
AwgTextField {
id: controlledJunk2TextField
2025-07-07 12:03:25 +08:00
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("J2 - Second controlled junk packet")
textField.text: clientControlledJunk2
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientControlledJunk2) {
clientControlledJunk2 = textField.text
2025-07-07 12:03:25 +08:00
}
}
}
2025-07-07 12:03:25 +08:00
AwgTextField {
id: controlledJunk3TextField
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: qsTr("J3 - Third controlled junk packet")
textField.text: clientControlledJunk3
textField.validator: null
checkEmptyText: false
textField.onEditingFinished: {
if (textField.text !== clientControlledJunk3) {
clientControlledJunk3 = textField.text
2025-07-07 12:03:25 +08:00
}
}
}
AwgTextField {
id: iTimeTextField
Layout.leftMargin: 16
Layout.rightMargin: 16
2025-07-07 12:03:25 +08:00
headerText: qsTr("Itime - Special handshake timeout")
textField.text: clientSpecialHandshakeTimeout
checkEmptyText: false
2025-07-07 12:03:25 +08:00
textField.onEditingFinished: {
if (textField.text !== clientSpecialHandshakeTimeout) {
clientSpecialHandshakeTimeout = textField.text
2025-07-07 12:03:25 +08:00
}
2024-12-31 04:16:52 +01:00
}
}
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
// AwgTextField {
// id: cookieReplyPacketJunkSizeTextField
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: "S3 - Cookie Reply packet junk size"
// textField.text: serverCookieReplyPacketJunkSize
// }
2024-09-13 12:38:48 +04:00
// AwgTextField {
// id: transportPacketJunkSizeTextField
2024-12-31 04:16:52 +01:00
// Layout.leftMargin: 16
// Layout.rightMargin: 16
// enabled: false
// 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() {
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() {}
2024-09-13 12:38:48 +04:00
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
}
}
}