feat: Add local address to wireguard

This commit is contained in:
Nova 2024-08-26 17:34:56 +03:30
parent 26eefee4b9
commit 88afb27c42
No known key found for this signature in database
GPG Key ID: 389787EC83F5D73A
6 changed files with 55 additions and 33 deletions

View File

@ -264,7 +264,7 @@ namespace NekoGui_fmt {
{"server", serverAddress},
{"server_port", serverPort},
{"interface_name", tun_name},
{"local_address", QJsonArray{"172.20.0.1/24", "fdfe:dcba:9876::1/96"}},
{"local_address", QListStr2QJsonArray(localAddress)},
{"private_key", privateKey},
{"peer_public_key", publicKey},
{"pre_shared_key", preSharedKey},

View File

@ -266,6 +266,7 @@ namespace NekoGui_fmt {
q.addQueryItem("reserved", FormatReserved());
q.addQueryItem("mtu", Int2String(MTU));
q.addQueryItem("use_system_interface", useSystemInterface ? "true":"false");
q.addQueryItem("local_address", localAddress.join("-"));
url.setQuery(q);
return url.toString(QUrl::FullyEncoded);
}

View File

@ -361,6 +361,10 @@ namespace NekoGui_fmt {
if (!rawReserved.isEmpty()) {
for (const auto &item: rawReserved.split("-")) reserved += item.toInt();
}
auto rawLocalAddr = query.queryItemValue("local_address");
if (!rawLocalAddr.isEmpty()) {
for (const auto &item: rawLocalAddr.split("-")) localAddress += item;
}
MTU = query.queryItemValue("mtu").toInt();
useSystemInterface = query.queryItemValue("use_system_interface") == "true";

View File

@ -9,6 +9,7 @@ namespace NekoGui_fmt {
QString publicKey;
QString preSharedKey;
QList<int> reserved;
QStringList localAddress;
int MTU = 1420;
bool useSystemInterface = false;
bool enableGSO = false;
@ -18,6 +19,7 @@ namespace NekoGui_fmt {
_add(new configItem("public_key", &publicKey, itemType::string));
_add(new configItem("pre_shared_key", &preSharedKey, itemType::string));
_add(new configItem("reserved", &reserved, itemType::integerList));
_add(new configItem("local_address", &localAddress, itemType::stringList));
_add(new configItem("mtu", &MTU, itemType::integer));
_add(new configItem("use_system_proxy", &useSystemInterface, itemType::boolean));
_add(new configItem("enable_gso", &enableGSO, itemType::boolean));

View File

@ -28,6 +28,7 @@ void EditWireguard::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) {
ui->mtu->setText(Int2String(bean->MTU));
ui->sys_ifc->setChecked(bean->useSystemInterface);
ui->enable_gso->setChecked(bean->enableGSO);
ui->local_addr->setText(bean->localAddress.join(","));
}
bool EditWireguard::onEnd() {
@ -45,6 +46,7 @@ bool EditWireguard::onEnd() {
bean->MTU = ui->mtu->text().toInt();
bean->useSystemInterface = ui->sys_ifc->isChecked();
bean->enableGSO = ui->enable_gso->isChecked();
bean->localAddress = ui->local_addr->text().replace(" ", "").split(",");
return true;
}

View File

@ -14,29 +14,10 @@
<string>EditWireguard</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="1">
<widget class="QLineEdit" name="reserved"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="public_key"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="private_key"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="public_key_l">
<item row="7" column="0">
<widget class="QLabel" name="mtu_l">
<property name="text">
<string>Public Key</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="preshared_key"/>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="enable_gso">
<property name="text">
<string>Enable GSO</string>
<string>MTU</string>
</property>
</widget>
</item>
@ -47,20 +28,26 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="private_key_l">
<item row="7" column="1">
<widget class="QLineEdit" name="mtu">
<property name="text">
<string>Private Key</string>
<string>1420</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QCheckBox" name="sys_ifc">
<property name="text">
<string>Use System Interface</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="reserved"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="private_key"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="reserved_l">
<property name="text">
@ -68,17 +55,43 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="mtu">
<item row="2" column="0">
<widget class="QLabel" name="private_key_l">
<property name="text">
<string>1420</string>
<string>Private Key</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="mtu_l">
<item row="9" column="1">
<widget class="QCheckBox" name="enable_gso">
<property name="text">
<string>MTU</string>
<string>Enable GSO</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="preshared_key"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="public_key_l">
<property name="text">
<string>Public Key</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="public_key"/>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="local_addr"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="local_addr_l">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;comma seperated list of subnets&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Local Address</string>
</property>
</widget>
</item>