Closed CamberLoid closed 3 years ago
any use example?
For example a.b.example.tld the regex will consider b.example.tld as main domain but the true main domain is example.tld
please help check https://github.com/honwen/aliyun-ddns-cli/releases/tag/v2021-04-11
Test failed. No support for tld like co.kr
Test code:
package main
import (
"log"
"fmt"
"strings"
"github.com/asaskevich/govalidator"
)
func splitDomain(fulldomain string) (rr, domain string) {
wildCard := false
if strings.HasPrefix(fulldomain, `*.`) {
wildCard = true
fulldomain = fulldomain[2:]
}
for len(fulldomain) > 0 && strings.HasSuffix(fulldomain, `.`) {
fulldomain = fulldomain[:len(fulldomain)-1]
}
subs := strings.Split(fulldomain, `.`)
if !govalidator.IsDNSName(fulldomain) || len(subs) < 2 {
log.Fatal("Not a Vaild Domain")
}
rrSubs := subs[:len(subs)-2]
domainSubs := subs[len(subs)-2:]
if wildCard {
rr = strings.Join(append([]string{`*`}, rrSubs...), `.`)
} else {
rr = strings.Join(rrSubs, `.`)
}
if len(rr) == 0 {
rr = `@`
}
domain = strings.Join(domainSubs, `.`)
// fmt.Println(rr, domain)
return
}
func main() {
a,b := splitDomain("ko.no.example.co.kr")
fmt.Print(a)
fmt.Print("\n")
fmt.Print(b)
}
Example output:
camber@Camber-Windoge ~/test.go % ./test
ko.no.example
co.kr%
Expected output:
ko.no
example.co.kr
Test environment Windows Subsystem Linux / Ubuntu 21.10(Development branch) go version go1.16 linux/amd64
does AliCloud NS support example.co.kr
as main domain?
please help check https://github.com/honwen/aliyun-ddns-cli/releases/tag/v2021-04-13
reopen a issues if meet any problem
发现原仓库的域名解析有Bug,没有对主域名/子域名的支持 因此加入了一些不太优雅写出来的另外几种方法 在本地编译通过并投入生产环境使用
由于本人没有Golang开发经验,因此本pr需要仓库作者修改或者指导
谢谢