支持自定义HTTP DNS

This commit is contained in:
GoEdgeLab
2021-01-28 11:29:57 +08:00
parent a73a04521d
commit 8eb6538c44
3 changed files with 225 additions and 3 deletions

View File

@@ -0,0 +1,45 @@
package dnsclients
import (
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"testing"
)
func TestCustomHTTPProvider_AddRecord(t *testing.T) {
provider := CustomHTTPProvider{}
err := provider.Auth(maps.Map{
"url": "http://127.0.0.1:1234/dns",
"secret": "123456",
})
if err != nil {
t.Fatal(err)
}
err = provider.AddRecord("hello.com", &Record{
Id: "",
Name: "world",
Type: RecordTypeA,
Value: "127.0.0.1",
Route: "default",
})
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}
func TestCustomHTTPProvider_GetRecords(t *testing.T) {
provider := CustomHTTPProvider{}
err := provider.Auth(maps.Map{
"url": "http://127.0.0.1:1234/dns",
"secret": "123456",
})
if err != nil {
t.Fatal(err)
}
records, err := provider.GetRecords("hello.com")
if err != nil {
t.Fatal(err)
}
logs.PrintAsJSON(records, t)
}