mirror of
https://github.com/jeessy2/ddns-go.git
synced 2025-10-20 23:43:45 +08:00
45 lines
1.0 KiB
Go
Executable File
45 lines
1.0 KiB
Go
Executable File
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/jeessy2/ddns-go/v6/util"
|
|
|
|
"github.com/jeessy2/ddns-go/v6/config"
|
|
)
|
|
|
|
// WebhookTest 测试webhook
|
|
func WebhookTest(writer http.ResponseWriter, request *http.Request) {
|
|
url := strings.TrimSpace(request.FormValue("URL"))
|
|
requestBody := strings.TrimSpace(request.FormValue("RequestBody"))
|
|
webhookHeaders := strings.TrimSpace(request.FormValue("WebhookHeaders"))
|
|
|
|
var domains = make([]*config.Domain, 1)
|
|
domains[0] = &config.Domain{}
|
|
domains[0].DomainName = "example.com"
|
|
domains[0].SubDomain = "test"
|
|
domains[0].UpdateStatus = config.UpdatedSuccess
|
|
|
|
fakeDomains := &config.Domains{
|
|
Ipv4Addr: "127.0.0.1",
|
|
Ipv4Domains: domains,
|
|
Ipv6Addr: "::1",
|
|
Ipv6Domains: domains,
|
|
}
|
|
|
|
fakeConfig := &config.Config{
|
|
Webhook: config.Webhook{
|
|
WebhookURL: url,
|
|
WebhookRequestBody: requestBody,
|
|
WebhookHeaders: webhookHeaders,
|
|
},
|
|
}
|
|
|
|
if url != "" {
|
|
config.ExecWebhook(fakeDomains, fakeConfig)
|
|
} else {
|
|
util.Log("请输入Webhook的URL")
|
|
}
|
|
}
|