shawn1m / overture

A customized DNS relay server
MIT License
1.79k stars 284 forks source link

Host file support one domain have ipv4 and ipv6 same time (#185) #189

Closed SharerMax closed 4 years ago

shawn1m commented 4 years ago

Thanks for your PR! Please explain the idea of your code in few words. I'm a little bit confused. In my point of view, I think the "check existing" and "add" method must be reimplemented to support ipv4 and ipv6 at the same time...

SharerMax commented 4 years ago

Sorry.

type hostsLine struct {
    domain string
    ip     net.IP
    ipv6   bool
}

when execute parseLine function, ipv6 has been set. so if ip is ipv4 the ipv6 is false and if ip is ipv6 the ipv6 is true.

I think domain and ipv6 indicate one unique host record. so we can compare domain and ipv6 to determine host reocrd whether exist or not exist.

shawn1m commented 4 years ago

Merged. It seems work, I will check it when I have enough time. Thanks!

SharerMax commented 4 years ago

I have a lite confused thing about ipv6 field. Why use ip.to4() or ip.to6() to detaermine ip type not ipv6 field in FindHosts(code link) method?