Closed codingm0nkey closed 3 years ago
Hello, which provider are you using?
HE
All provider have such problem,too I think the request logic should be updated. In settings.go
// Domain struct
type Domain struct {
DomainName string `json:"domain_name"`
SubDomains []SubDomain `json:"sub_domains"`
}
// SubDomain struct
type SubDomain struct {
SubDomainName string `json:"subdomain_name"`
SubDomainType string `json:"subdomain_type"`
}
When getting current record
for _, subDomain := range domain.SubDomains {
hostname := subDomain.SubDomainName + "." + domain.DomainName
lastIP, err := godns.ResolveDNS(hostname, handler.Configuration.Resolver, subDomain.SubDomainType)
if err != nil {
log.Println(err)
continue
}
balabala...
}
When Updating
// Resolve API Host in IPv4/v6
APIHost:=GetAddress(AddressFamily)
//check against currently known IP, if no change, skip update
if currentIP == lastIP {
log.Printf("IP is the same as cached one. Skip update.\n")
} else {
req, _ := http.NewRequest("GET", fmt.Sprintf(
APIHost, // Connect Host by IP
handler.Configuration.Email,
handler.Configuration.Password,
hostname,
ip), nil)
if handler.Configuration.UserAgent != "" {
req.Header.Add("User-Agent", handler.Configuration.UserAgent)
req.Header.Add("Host", APIHostAddr) //Add Host Header,Important!
}
// update IP with HTTP GET request
resp, err := client.Do(req)
if err != nil {
// handle error
log.Print("Failed to update sub domain:", subDomain)
continue
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil || !strings.Contains(string(body), "good") {
log.Println("Failed to update the IP")
continue
} else {
log.Print("IP updated to:", currentIP)
}
// Send notification
if err := godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP); err != nil {
log.Println("Failed to send notification")
}
}
Thanks, I'll investigate it.
I used one domain hosted at HE and tried to reproduce it, but it seems cannot reproduce.
I configured 2 same sub-domains: godns, one for IPV4 and one for IPV6
The output of GoDNS:
[GoDNS] 2021/03/13 20:10:10 GoDNS started, entering main loop...
[GoDNS] 2021/03/13 20:10:10 Creating DNS handler with provider: HE
[GoDNS] 2021/03/13 20:10:10 currentIP is: 2xxx:3xxx:2077:192a:a196:c8ec:9c72:aacd
[GoDNS] 2021/03/13 20:10:11 godns.example.com Start to update record IP...
[GoDNS] 2021/03/13 20:10:11 Update IP success: good 2xxx:3xxx:2077:192a:a196:c8ec:9c72:aacd
[GoDNS] 2021/03/13 20:10:11 Sending notification to: notify@example.com
[GoDNS] 2021/03/13 20:10:11 currentIP: 2xxx:3xxx:2077:192a:a196:c8ec:9c72:aacd
[GoDNS] 2021/03/13 20:10:11 domain: godns.example.com
The configuration is:
{
"provider": "HE",
"password": "password_for_He",
"domains": [{
"domain_name": "example.com",
"sub_domains": ["godns"]
}],
"resolver": "8.8.8.8",
"ipv6_url": "https://api-ipv6.ip.sb/ip",
"ip_type": "IPV6",
"interval": 300,
"socks5_proxy": ""
}
Same problem with cloudflare and ipv6 subdomain, both subdomain and main domain takes subdomain ipv6 address, ipv4 looks OK
upd:
мар 26 19:44:33 odroid systemd[1]: Started GoDNS Service.
мар 26 19:44:33 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:33 GoDNS started, entering main loop...
мар 26 19:44:33 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:33 Creating DNS handler with provider: Cloudflare
мар 26 19:44:34 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:34 Current IP is: 2a02:XX:XX:d00:21e:6ff:fe49:42
мар 26 19:44:34 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:34 Checking IP for domain zzz.win
мар 26 19:44:36 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:36 Querying records with type: AAAA
мар 26 19:44:36 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:36 Record OK: atom.zzz.win - 2a02:XX:XX:d00:21e:6ff:fe49:42
мар 26 19:44:36 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:36 IP mismatch: Current(2a02:XX:XX:d00:21e:6ff:fe49:42) vs Cloudflare(2a01:XX:XX:dd4f::1)
мар 26 19:44:38 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:38 Record updated: zzz.win - 2a02:XX:XX:d00:21e:6ff:fe49:42
мар 26 19:44:38 odroid godns[88128]: [GoDNS] 2021/03/26 19:44:38 Going to sleep, will start next checking in 300 seconds...
{
"provider": "Cloudflare",
"login_token": "zz",
"domains": [{
"domain_name": "zz.win",
"sub_domains": ["atom"]
}],
"ipv6_url": "https://api-ipv6.ip.sb/ip",
"ip_type": "IPv6",
"interval": 300,
"resolver": "2001:4860:4860::8888",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36",
"ip_interface": "eth0",
"socks5_proxy": "",
"use_proxy": false,
"notify": {
"telegram": {
"enabled": true,
"bot_api_key": "zz",
"chat_id": "zz",
"message_template": "Domain *{{ .Domain }}* is updated to %0A{{ .CurrentIP }}",
"use_proxy": false
}
}
}
Please add Type check about subdomain in config
I have 2 record,
PC.example.com. A 127.0.0.1
PC.example.com,AAAA fe80::1111
If I write like this,The program will change 2 records in the same time.
{ "domains": [ { "domain_name": "example.com", "sub_domains": [ "PC" ] } ] }
If I want modify AAAA record only,it seems impossible.
I think the best solution is add Type definition in configuration.