From 36b2a586756fc279304170976c9d486498d55919 Mon Sep 17 00:00:00 2001 From: Peter Liu <30622363+PedroLiu1999@users.noreply.github.com> Date: Sun, 19 Apr 2026 23:41:50 +0100 Subject: [PATCH] feat: Add NordVPN NordLynx (WireGuard) integration (#3827) * feat: Add NordVPN NordLynx (WireGuard) integration with dedicated UI and backend services. * remove limit=10 to get all servers * feat: add city selector to NordVPN modal * feat: auto-select best server on country/city change * feat: simplify filter logic and enforce > 7% load * fix --------- Co-authored-by: Sanaei --- web/controller/xray_setting.go | 28 +++ web/html/modals/nord_modal.html | 306 ++++++++++++++++++++++++++ web/html/settings/xray/basics.html | 19 ++ web/html/settings/xray/outbounds.html | 2 + web/html/xray.html | 22 ++ web/service/nord.go | 145 ++++++++++++ web/service/setting.go | 9 + web/translation/translate.ar_EG.toml | 12 + web/translation/translate.en_US.toml | 12 + web/translation/translate.es_ES.toml | 12 + web/translation/translate.fa_IR.toml | 12 + web/translation/translate.id_ID.toml | 12 + web/translation/translate.ja_JP.toml | 12 + web/translation/translate.pt_BR.toml | 12 + web/translation/translate.ru_RU.toml | 14 +- web/translation/translate.tr_TR.toml | 12 + web/translation/translate.uk_UA.toml | 12 + web/translation/translate.vi_VN.toml | 12 + web/translation/translate.zh_CN.toml | 12 + web/translation/translate.zh_TW.toml | 12 + 20 files changed, 688 insertions(+), 1 deletion(-) create mode 100644 web/html/modals/nord_modal.html create mode 100644 web/service/nord.go diff --git a/web/controller/xray_setting.go b/web/controller/xray_setting.go index 5b7a0e26..0c382fb9 100644 --- a/web/controller/xray_setting.go +++ b/web/controller/xray_setting.go @@ -17,6 +17,7 @@ type XraySettingController struct { OutboundService service.OutboundService XrayService service.XrayService WarpService service.WarpService + NordService service.NordService } // NewXraySettingController creates a new XraySettingController and initializes its routes. @@ -35,6 +36,7 @@ func (a *XraySettingController) initRouter(g *gin.RouterGroup) { g.POST("/", a.getXraySetting) g.POST("/warp/:action", a.warp) + g.POST("/nord/:action", a.nord) g.POST("/update", a.updateSetting) g.POST("/resetOutboundsTraffic", a.resetOutboundsTraffic) g.POST("/testOutbound", a.testOutbound) @@ -123,6 +125,32 @@ func (a *XraySettingController) warp(c *gin.Context) { jsonObj(c, resp, err) } +// nord handles NordVPN-related operations based on the action parameter. +func (a *XraySettingController) nord(c *gin.Context) { + action := c.Param("action") + var resp string + var err error + switch action { + case "countries": + resp, err = a.NordService.GetCountries() + case "servers": + countryId := c.PostForm("countryId") + resp, err = a.NordService.GetServers(countryId) + case "reg": + token := c.PostForm("token") + resp, err = a.NordService.GetCredentials(token) + case "setKey": + key := c.PostForm("key") + resp, err = a.NordService.SetKey(key) + case "data": + resp, err = a.NordService.GetNordData() + case "del": + err = a.NordService.DelNordData() + } + + jsonObj(c, resp, err) +} + // getOutboundsTraffic retrieves the traffic statistics for outbounds. func (a *XraySettingController) getOutboundsTraffic(c *gin.Context) { outboundsTraffic, err := a.OutboundService.GetOutboundsTraffic() diff --git a/web/html/modals/nord_modal.html b/web/html/modals/nord_modal.html new file mode 100644 index 00000000..c86d8ed9 --- /dev/null +++ b/web/html/modals/nord_modal.html @@ -0,0 +1,306 @@ +{{define "modals/nordModal"}} + + + + + + +{{end}} diff --git a/web/html/settings/xray/basics.html b/web/html/settings/xray/basics.html index 9a31038a..c637e30a 100644 --- a/web/html/settings/xray/basics.html +++ b/web/html/settings/xray/basics.html @@ -313,6 +313,25 @@ + + + + diff --git a/web/html/settings/xray/outbounds.html b/web/html/settings/xray/outbounds.html index 3995760f..232fe55e 100644 --- a/web/html/settings/xray/outbounds.html +++ b/web/html/settings/xray/outbounds.html @@ -9,6 +9,8 @@ WARP + NordVPN diff --git a/web/html/xray.html b/web/html/xray.html index 040ae2ee..01b4e4e2 100644 --- a/web/html/xray.html +++ b/web/html/xray.html @@ -163,6 +163,7 @@ {{template "modals/dnsPresetsModal"}} {{template "modals/fakednsModal"}} {{template "modals/warpModal"}} +{{template "modals/nordModal"}}