diff --git a/include/configs/proxy/WireguardBean.h b/include/configs/proxy/WireguardBean.h index 5baf585..ad93f0e 100644 --- a/include/configs/proxy/WireguardBean.h +++ b/include/configs/proxy/WireguardBean.h @@ -9,6 +9,7 @@ namespace NekoGui_fmt { QString publicKey; QString preSharedKey; QList reserved; + int persistentKeepalive = 0; QStringList localAddress; int MTU = 1420; bool useSystemInterface = false; @@ -20,6 +21,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("persistent_keepalive", &persistentKeepalive, itemType::integer)); _add(new configItem("local_address", &localAddress, itemType::stringList)); _add(new configItem("mtu", &MTU, itemType::integer)); _add(new configItem("use_system_proxy", &useSystemInterface, itemType::boolean)); diff --git a/include/ui/profile/edit_wireguard.ui b/include/ui/profile/edit_wireguard.ui index d218e9e..f4e42b4 100644 --- a/include/ui/profile/edit_wireguard.ui +++ b/include/ui/profile/edit_wireguard.ui @@ -7,27 +7,33 @@ 0 0 400 - 300 + 326 EditWireguard - - + + + + + - Reserved + Public Key - - - - <html><head/><body><p>comma seperated list of subnets</p></body></html> - + + + + + + + + - Local Address + Enable GSO @@ -38,35 +44,35 @@ - + - - + + + + <html><head/><body><p>comma seperated list of subnets</p></body></html> + + + Local Address + + - + + + + MTU + + + + Use System Interface - - - - Enable GSO - - - - - - - Public Key - - - - - + + @@ -75,27 +81,10 @@ - - + + - - - - - - - 1420 - - - - - - - MTU - - - - + Workers @@ -103,7 +92,34 @@ - + + + 1420 + + + + + + + Reserved + + + + + + + + + + <html><head/><body><p>persistent_keepalive_interval in seconds</p></body></html> + + + <html><head/><body><p><br/></p></body></html> + + + Persistent Keepalive + + diff --git a/src/configs/proxy/Bean2CoreObj_box.cpp b/src/configs/proxy/Bean2CoreObj_box.cpp index 19f0628..e9f13f6 100644 --- a/src/configs/proxy/Bean2CoreObj_box.cpp +++ b/src/configs/proxy/Bean2CoreObj_box.cpp @@ -287,6 +287,7 @@ namespace NekoGui_fmt { {"pre_shared_key", preSharedKey}, {"reserved", QListInt2QJsonArray(reserved)}, {"allowed_ips", QListStr2QJsonArray({"0.0.0.0/0", "::/0"})}, + {"persistent_keepalive_interval", persistentKeepalive}, }; QJsonObject outbound{ {"type", "wireguard"}, diff --git a/src/configs/proxy/Bean2Link.cpp b/src/configs/proxy/Bean2Link.cpp index b03bafc..a147645 100644 --- a/src/configs/proxy/Bean2Link.cpp +++ b/src/configs/proxy/Bean2Link.cpp @@ -260,6 +260,7 @@ namespace NekoGui_fmt { q.addQueryItem("peer_public_key", publicKey); q.addQueryItem("pre_shared_key", preSharedKey); q.addQueryItem("reserved", FormatReserved()); + q.addQueryItem("persistent_keepalive", Int2String(persistentKeepalive)); q.addQueryItem("mtu", Int2String(MTU)); q.addQueryItem("use_system_interface", useSystemInterface ? "true":"false"); q.addQueryItem("local_address", localAddress.join("-")); diff --git a/src/configs/proxy/Json2Bean.cpp b/src/configs/proxy/Json2Bean.cpp index e33b49e..580a5a1 100644 --- a/src/configs/proxy/Json2Bean.cpp +++ b/src/configs/proxy/Json2Bean.cpp @@ -215,6 +215,7 @@ namespace NekoGui_fmt serverPort = peers[0].toObject()["port"].toInt(); publicKey = peers[0].toObject()["public_key"].toString(); reserved = QJsonArray2QListInt(peers[0].toObject()["reserved"].toArray()); + persistentKeepalive = peers[0].toObject()["persistent_keepalive_interval"].toInt(); workerCount = obj["workers"].toInt(); privateKey = obj["private_key"].toString(); localAddress = QJsonArray2QListString(obj["address"].toArray()); diff --git a/src/configs/proxy/Link2Bean.cpp b/src/configs/proxy/Link2Bean.cpp index da08dda..1c1d545 100644 --- a/src/configs/proxy/Link2Bean.cpp +++ b/src/configs/proxy/Link2Bean.cpp @@ -358,6 +358,7 @@ namespace NekoGui_fmt { if (!rawLocalAddr.isEmpty()) { for (const auto &item: rawLocalAddr.split("-")) localAddress += item; } + persistentKeepalive = query.queryItemValue("persistent_keepalive").toInt(); MTU = query.queryItemValue("mtu").toInt(); useSystemInterface = query.queryItemValue("use_system_interface") == "true"; workerCount = query.queryItemValue("workers").toInt(); diff --git a/src/ui/profile/edit_wireguard.cpp b/src/ui/profile/edit_wireguard.cpp index 6a012c2..7112bac 100644 --- a/src/ui/profile/edit_wireguard.cpp +++ b/src/ui/profile/edit_wireguard.cpp @@ -24,6 +24,7 @@ void EditWireguard::onStart(std::shared_ptr _ent) { ui->preshared_key->setText(bean->preSharedKey); auto reservedStr = bean->FormatReserved().replace("-", ","); ui->reserved->setText(reservedStr); + ui->persistent_keepalive->setText(Int2String(bean->persistentKeepalive)); ui->mtu->setText(Int2String(bean->MTU)); ui->sys_ifc->setChecked(bean->useSystemInterface); ui->enable_gso->setChecked(bean->enableGSO); @@ -43,6 +44,7 @@ bool EditWireguard::onEnd() { if (item.trimmed().isEmpty()) continue; bean->reserved += item.trimmed().toInt(); } + bean->persistentKeepalive = ui->persistent_keepalive->text().toInt(); bean->MTU = ui->mtu->text().toInt(); bean->useSystemInterface = ui->sys_ifc->isChecked(); bean->enableGSO = ui->enable_gso->isChecked();