add persistent_keepalive_interval to wireguard

This commit is contained in:
Nova 2025-04-13 04:12:15 +03:30
parent bed488a068
commit 437f583e05
7 changed files with 75 additions and 51 deletions

View File

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

View File

@ -7,27 +7,33 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>300</height> <height>326</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>EditWireguard</string> <string>EditWireguard</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="5" column="0"> <item row="3" column="1">
<widget class="QLabel" name="reserved_l"> <widget class="QLineEdit" name="public_key"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="public_key_l">
<property name="text"> <property name="text">
<string>Reserved</string> <string>Public Key</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="5" column="1">
<widget class="QLabel" name="local_addr_l"> <widget class="QLineEdit" name="reserved"/>
<property name="toolTip"> </item>
<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> <item row="4" column="1">
</property> <widget class="QLineEdit" name="preshared_key"/>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="enable_gso">
<property name="text"> <property name="text">
<string>Local Address</string> <string>Enable GSO</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -38,35 +44,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<widget class="QLineEdit" name="local_addr"/> <widget class="QLineEdit" name="local_addr"/>
</item> </item>
<item row="5" column="1"> <item row="7" column="0">
<widget class="QLineEdit" name="reserved"/> <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> </item>
<item row="9" column="1"> <item row="8" column="0">
<widget class="QLabel" name="mtu_l">
<property name="text">
<string>MTU</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="sys_ifc"> <widget class="QCheckBox" name="sys_ifc">
<property name="text"> <property name="text">
<string>Use System Interface</string> <string>Use System Interface</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1"> <item row="2" column="1">
<widget class="QCheckBox" name="enable_gso"> <widget class="QLineEdit" name="private_key"/>
<property name="text">
<string>Enable GSO</string>
</property>
</widget>
</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="4" column="1">
<widget class="QLineEdit" name="preshared_key"/>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="private_key_l"> <widget class="QLabel" name="private_key_l">
@ -75,27 +81,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="9" column="1">
<widget class="QLineEdit" name="public_key"/> <widget class="QLineEdit" name="workers"/>
</item> </item>
<item row="2" column="1"> <item row="9" column="0">
<widget class="QLineEdit" name="private_key"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="mtu">
<property name="text">
<string>1420</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="mtu_l">
<property name="text">
<string>MTU</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="workers_l"> <widget class="QLabel" name="workers_l">
<property name="text"> <property name="text">
<string>Workers</string> <string>Workers</string>
@ -103,7 +92,34 @@
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="8" column="1">
<widget class="QLineEdit" name="workers"/> <widget class="QLineEdit" name="mtu">
<property name="text">
<string>1420</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="reserved_l">
<property name="text">
<string>Reserved</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="persistent_keepalive"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;persistent_keepalive_interval in seconds&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Persistent Keepalive</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -287,6 +287,7 @@ namespace NekoGui_fmt {
{"pre_shared_key", preSharedKey}, {"pre_shared_key", preSharedKey},
{"reserved", QListInt2QJsonArray(reserved)}, {"reserved", QListInt2QJsonArray(reserved)},
{"allowed_ips", QListStr2QJsonArray({"0.0.0.0/0", "::/0"})}, {"allowed_ips", QListStr2QJsonArray({"0.0.0.0/0", "::/0"})},
{"persistent_keepalive_interval", persistentKeepalive},
}; };
QJsonObject outbound{ QJsonObject outbound{
{"type", "wireguard"}, {"type", "wireguard"},

View File

@ -260,6 +260,7 @@ namespace NekoGui_fmt {
q.addQueryItem("peer_public_key", publicKey); q.addQueryItem("peer_public_key", publicKey);
q.addQueryItem("pre_shared_key", preSharedKey); q.addQueryItem("pre_shared_key", preSharedKey);
q.addQueryItem("reserved", FormatReserved()); q.addQueryItem("reserved", FormatReserved());
q.addQueryItem("persistent_keepalive", Int2String(persistentKeepalive));
q.addQueryItem("mtu", Int2String(MTU)); q.addQueryItem("mtu", Int2String(MTU));
q.addQueryItem("use_system_interface", useSystemInterface ? "true":"false"); q.addQueryItem("use_system_interface", useSystemInterface ? "true":"false");
q.addQueryItem("local_address", localAddress.join("-")); q.addQueryItem("local_address", localAddress.join("-"));

View File

@ -215,6 +215,7 @@ namespace NekoGui_fmt
serverPort = peers[0].toObject()["port"].toInt(); serverPort = peers[0].toObject()["port"].toInt();
publicKey = peers[0].toObject()["public_key"].toString(); publicKey = peers[0].toObject()["public_key"].toString();
reserved = QJsonArray2QListInt(peers[0].toObject()["reserved"].toArray()); reserved = QJsonArray2QListInt(peers[0].toObject()["reserved"].toArray());
persistentKeepalive = peers[0].toObject()["persistent_keepalive_interval"].toInt();
workerCount = obj["workers"].toInt(); workerCount = obj["workers"].toInt();
privateKey = obj["private_key"].toString(); privateKey = obj["private_key"].toString();
localAddress = QJsonArray2QListString(obj["address"].toArray()); localAddress = QJsonArray2QListString(obj["address"].toArray());

View File

@ -358,6 +358,7 @@ namespace NekoGui_fmt {
if (!rawLocalAddr.isEmpty()) { if (!rawLocalAddr.isEmpty()) {
for (const auto &item: rawLocalAddr.split("-")) localAddress += item; for (const auto &item: rawLocalAddr.split("-")) localAddress += item;
} }
persistentKeepalive = query.queryItemValue("persistent_keepalive").toInt();
MTU = query.queryItemValue("mtu").toInt(); MTU = query.queryItemValue("mtu").toInt();
useSystemInterface = query.queryItemValue("use_system_interface") == "true"; useSystemInterface = query.queryItemValue("use_system_interface") == "true";
workerCount = query.queryItemValue("workers").toInt(); workerCount = query.queryItemValue("workers").toInt();

View File

@ -24,6 +24,7 @@ void EditWireguard::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) {
ui->preshared_key->setText(bean->preSharedKey); ui->preshared_key->setText(bean->preSharedKey);
auto reservedStr = bean->FormatReserved().replace("-", ","); auto reservedStr = bean->FormatReserved().replace("-", ",");
ui->reserved->setText(reservedStr); ui->reserved->setText(reservedStr);
ui->persistent_keepalive->setText(Int2String(bean->persistentKeepalive));
ui->mtu->setText(Int2String(bean->MTU)); ui->mtu->setText(Int2String(bean->MTU));
ui->sys_ifc->setChecked(bean->useSystemInterface); ui->sys_ifc->setChecked(bean->useSystemInterface);
ui->enable_gso->setChecked(bean->enableGSO); ui->enable_gso->setChecked(bean->enableGSO);
@ -43,6 +44,7 @@ bool EditWireguard::onEnd() {
if (item.trimmed().isEmpty()) continue; if (item.trimmed().isEmpty()) continue;
bean->reserved += item.trimmed().toInt(); bean->reserved += item.trimmed().toInt();
} }
bean->persistentKeepalive = ui->persistent_keepalive->text().toInt();
bean->MTU = ui->mtu->text().toInt(); bean->MTU = ui->mtu->text().toInt();
bean->useSystemInterface = ui->sys_ifc->isChecked(); bean->useSystemInterface = ui->sys_ifc->isChecked();
bean->enableGSO = ui->enable_gso->isChecked(); bean->enableGSO = ui->enable_gso->isChecked();