feat: support dynv6

This commit is contained in:
chinhwajie
2024-10-25 16:12:07 +08:00
parent 938421fcc8
commit f18ca66786
7 changed files with 190 additions and 4 deletions

View File

@@ -3,6 +3,9 @@ package dns
import (
"errors"
"fmt"
"io"
"net/http"
"github.com/Mmx233/BitSrunLoginGo/internal/dns/aliyun"
"github.com/Mmx233/BitSrunLoginGo/internal/dns/cloudflare"
"github.com/Mmx233/BitSrunLoginGo/internal/dns/dnspod"
@@ -28,6 +31,25 @@ func Run(c *Config) error {
dns, err = cloudflare.New(int(c.TTL), c.Conf.Cloudflare, c.Http)
case "dnspod":
dns, err = dnspod.New(uint64(c.TTL), c.Conf.DnsPod, c.Http.Transport)
case "dynv6":
url := fmt.Sprintf(
"http://dynv6.com/api/update?hostname=%s&token=%s&ipv4=%s", c.Domain, c.Conf.Token, c.IP)
// Make the HTTP GET request
resp, err := http.Get(url)
if err != nil {
c.Logger.Error(err)
return err
}
// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
c.Logger.Error(err)
return err
}
// Print the response
c.Logger.Debug(string(body))
resp.Body.Close()
default:
var msg string
if c.Provider == "" {