支持自定义HTTP DNS

This commit is contained in:
GoEdgeLab
2021-01-28 11:29:50 +08:00
parent 8971d939ba
commit 3f656a859d
5 changed files with 78 additions and 1 deletions

View File

@@ -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 + "'")
}

View File

@@ -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 + "'")
}

View File

@@ -18,7 +18,6 @@
<option value="">[请选择]</option>
<option v-for="type in types" :value="type.code">{{type.name}}</option>
</select>
<p class="comment">创建后无法修改此选项。</p>
</td>
</tr>
<tr>
@@ -78,6 +77,24 @@
</td>
</tr>
</tbody>
<!-- 自定义HTTP-->
<tbody v-if="type == 'customHTTP'">
<tr>
<td>HTTP URL *</td>
<td>
<input type="text" name="paramCustomHTTPURL" maxlength="200"/>
<p class="comment">HTTP URL完整地址DNS所有操作都会以POST的方式转发到此地址。</p>
</td>
</tr>
<tr>
<td>私钥 *</td>
<td>
<input type="text" name="paramCustomHTTPSecret" maxlength="64" v-model="paramCustomHTTPSecret"/>
<p class="comment">通讯用的私钥转发请求时会在Header中加入相关信息方便开发者校验请求是否合法。</p>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>

View File

@@ -42,6 +42,18 @@
<td>{{provider.apiParams.accessKeySecret}}</td>
</tr>
</tbody>
<!-- CustomHTTP -->
<tbody v-if="provider.type == 'customHTTP'">
<tr>
<td>HTTP URL</td>
<td>{{provider.apiParams.url}}</td>
</tr>
<tr>
<td>私钥</td>
<td>{{provider.apiParams.secret}}</td>
</tr>
</tbody>
</table>

View File

@@ -59,6 +59,24 @@
</td>
</tr>
</tbody>
<!-- 自定义HTTP-->
<tbody v-if="provider.type == 'customHTTP'">
<tr>
<td>HTTP URL *</td>
<td>
<input type="text" name="paramCustomHTTPURL" maxlength="200" v-model="provider.params.url"/>
<p class="comment">HTTP URL完整地址DNS所有操作都会以POST的方式转发到此地址。</p>
</td>
</tr>
<tr>
<td>私钥 *</td>
<td>
<input type="text" name="paramCustomHTTPSecret" maxlength="64" v-model="provider.params.secret"/>
<p class="comment">通讯用的私钥转发请求时会在Header中加入相关信息方便开发者校验请求是否合法。</p>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>