From 3f656a859d5b424fa8f79ff8e8e19ff6eac14aea Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 28 Jan 2021 11:29:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89HT?= =?UTF-8?q?TP=20DNS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/dns/providers/createPopup.go | 17 +++++++++++++++++ .../default/dns/providers/updatePopup.go | 13 +++++++++++++ .../@default/dns/providers/createPopup.html | 19 ++++++++++++++++++- .../@default/dns/providers/provider.html | 12 ++++++++++++ .../@default/dns/providers/updatePopup.html | 18 ++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/internal/web/actions/default/dns/providers/createPopup.go b/internal/web/actions/default/dns/providers/createPopup.go index 823f0712..8239aac3 100644 --- a/internal/web/actions/default/dns/providers/createPopup.go +++ b/internal/web/actions/default/dns/providers/createPopup.go @@ -6,6 +6,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/rands" ) type CreatePopupAction struct { @@ -32,6 +33,9 @@ func (this *CreatePopupAction) RunGet(params struct{}) { } this.Data["types"] = typeMaps + // 自动生成CustomHTTP私钥 + this.Data["paramCustomHTTPSecret"] = rands.HexString(32) + this.Show() } @@ -51,6 +55,10 @@ func (this *CreatePopupAction) RunPost(params struct { ParamApiKey string ParamApiSecret string + // CustomHTTP + ParamCustomHTTPURL string + ParamCustomHTTPSecret string + Must *actions.Must CSRF *actionutils.CSRF }) { @@ -89,6 +97,15 @@ func (this *CreatePopupAction) RunPost(params struct { apiParams["apiKey"] = params.ParamApiKey apiParams["apiSecret"] = params.ParamApiSecret + case "customHTTP": + params.Must. + Field("paramCustomHTTPURL", params.ParamCustomHTTPURL). + Require("请输入HTTP URL"). + Match("^(?i)(http|https):", "URL必须以http://或者https://开头"). + Field("paramCustomHTTPSecret", params.ParamCustomHTTPSecret). + Require("请输入私钥") + apiParams["url"] = params.ParamCustomHTTPURL + apiParams["secret"] = params.ParamCustomHTTPSecret default: this.Fail("暂时不支持此服务商'" + params.Type + "'") } diff --git a/internal/web/actions/default/dns/providers/updatePopup.go b/internal/web/actions/default/dns/providers/updatePopup.go index b54a3afa..cbca95cc 100644 --- a/internal/web/actions/default/dns/providers/updatePopup.go +++ b/internal/web/actions/default/dns/providers/updatePopup.go @@ -84,6 +84,10 @@ func (this *UpdatePopupAction) RunPost(params struct { ParamApiKey string ParamApiSecret string + // CustomHTTP + ParamCustomHTTPURL string + ParamCustomHTTPSecret string + Must *actions.Must CSRF *actionutils.CSRF }) { @@ -124,6 +128,15 @@ func (this *UpdatePopupAction) RunPost(params struct { apiParams["apiKey"] = params.ParamApiKey apiParams["apiSecret"] = params.ParamApiSecret + case "customHTTP": + params.Must. + Field("paramCustomHTTPURL", params.ParamCustomHTTPURL). + Require("请输入HTTP URL"). + Match("^(?i)(http|https):", "URL必须以http://或者https://开头"). + Field("paramCustomHTTPSecret", params.ParamCustomHTTPSecret). + Require("请输入私钥") + apiParams["url"] = params.ParamCustomHTTPURL + apiParams["secret"] = params.ParamCustomHTTPSecret default: this.Fail("暂时不支持此服务商'" + params.Type + "'") } diff --git a/web/views/@default/dns/providers/createPopup.html b/web/views/@default/dns/providers/createPopup.html index 3814c556..58bbfb93 100644 --- a/web/views/@default/dns/providers/createPopup.html +++ b/web/views/@default/dns/providers/createPopup.html @@ -18,7 +18,6 @@ -

创建后无法修改此选项。

@@ -78,6 +77,24 @@ + + + + + HTTP URL * + + +

HTTP URL完整地址,DNS所有操作都会以POST的方式转发到此地址。

+ + + + 私钥 * + + +

通讯用的私钥,转发请求时会在Header中加入相关信息,方便开发者校验请求是否合法。

+ + + diff --git a/web/views/@default/dns/providers/provider.html b/web/views/@default/dns/providers/provider.html index 16e4f4f9..c98e2691 100644 --- a/web/views/@default/dns/providers/provider.html +++ b/web/views/@default/dns/providers/provider.html @@ -42,6 +42,18 @@ {{provider.apiParams.accessKeySecret}} + + + + + HTTP URL + {{provider.apiParams.url}} + + + 私钥 + {{provider.apiParams.secret}} + + diff --git a/web/views/@default/dns/providers/updatePopup.html b/web/views/@default/dns/providers/updatePopup.html index 87254619..b9c43060 100644 --- a/web/views/@default/dns/providers/updatePopup.html +++ b/web/views/@default/dns/providers/updatePopup.html @@ -59,6 +59,24 @@ + + + + + HTTP URL * + + +

HTTP URL完整地址,DNS所有操作都会以POST的方式转发到此地址。

+ + + + 私钥 * + + +

通讯用的私钥,转发请求时会在Header中加入相关信息,方便开发者校验请求是否合法。

+ + +