From bee690429f5a5a4639679236b414d42dbdd6b762 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Thu, 11 Jan 2024 09:57:21 +0330 Subject: WARP via wireguard Co-Authored-By: Alireza Ahmadi --- web/controller/xray_setting.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'web/controller') diff --git a/web/controller/xray_setting.go b/web/controller/xray_setting.go index d4deacd9..09e9115f 100644 --- a/web/controller/xray_setting.go +++ b/web/controller/xray_setting.go @@ -26,6 +26,7 @@ func (a *XraySettingController) initRouter(g *gin.RouterGroup) { g.POST("/update", a.updateSetting) g.GET("/getXrayResult", a.getXrayResult) g.GET("/getDefaultJsonConfig", a.getDefaultXrayConfig) + g.POST("/warp/:action", a.warp) } func (a *XraySettingController) getXraySetting(c *gin.Context) { @@ -61,3 +62,25 @@ func (a *XraySettingController) getDefaultXrayConfig(c *gin.Context) { func (a *XraySettingController) getXrayResult(c *gin.Context) { jsonObj(c, a.XrayService.GetXrayResult(), nil) } + +func (a *XraySettingController) warp(c *gin.Context) { + action := c.Param("action") + var resp string + var err error + switch action { + case "data": + resp, err = a.XraySettingService.GetWarp() + case "config": + resp, err = a.XraySettingService.GetWarpConfig() + case "reg": + skey := c.PostForm("privateKey") + pkey := c.PostForm("publicKey") + resp, err = a.XraySettingService.RegWarp(skey, pkey) + case "license": + license := c.PostForm("license") + println(license) + resp, err = a.XraySettingService.SetWarpLicence(license) + } + + jsonObj(c, resp, err) +} -- cgit v1.2.3