ddns: store configuation in database (#435)

* ddns: store configuation in database

Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com>

* feat: split domain with soa lookup

* switch to libdns interface

* ddns: add unit test

* ddns: skip TestSplitDomainSOA on ci

network is not steady

* fix error handling

* fix error handling

---------

Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com>
This commit is contained in:
UUBulb
2024-10-17 21:03:03 +08:00
committed by GitHub
parent 0b7f43b149
commit a503f0cf40
38 changed files with 1252 additions and 827 deletions

View File

@@ -21,6 +21,10 @@ func GjsonGet(json []byte, path string) (gjson.Result, error) {
}
func GjsonParseStringMap(jsonObject string) (map[string]string, error) {
if jsonObject == "" {
return nil, nil
}
result := gjson.Parse(jsonObject)
if !result.IsObject() {
return nil, ErrGjsonWrongType

View File

@@ -22,6 +22,8 @@ func init() {
SkipVerifySSL: false,
}),
})
http.DefaultClient.Timeout = time.Minute * 10
}
type _httpTransport struct {

View File

@@ -3,7 +3,6 @@ package utils
import (
"crypto/rand"
"math/big"
"net/http"
"os"
"regexp"
"strings"
@@ -11,7 +10,11 @@ import (
jsoniter "github.com/json-iterator/go"
)
var Json = jsoniter.ConfigCompatibleWithStandardLibrary
var (
Json = jsoniter.ConfigCompatibleWithStandardLibrary
DNSServers = []string{"1.1.1.1:53", "223.5.5.5:53", "[2606:4700:4700::1111]:53", "[2400:3200::1]:53"}
)
func IsWindows() bool {
return os.PathSeparator == '\\' && os.PathListSeparator == ';'
@@ -87,15 +90,3 @@ func Uint64SubInt64(a uint64, b int64) uint64 {
}
return a - uint64(b)
}
func SetStringHeadersToRequest(req *http.Request, headers []string) {
if req == nil {
return
}
for _, element := range headers {
kv := strings.SplitN(element, ":", 2)
if len(kv) == 2 {
req.Header.Add(kv[0], kv[1])
}
}
}