mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
add IPV6 support
This commit is contained in:
parent
85c21e6035
commit
6ec63e4499
@ -30,14 +30,14 @@ type Settings struct {
|
|||||||
LoginToken string `json:"login_token"`
|
LoginToken string `json:"login_token"`
|
||||||
Domains []Domain `json:"domains"`
|
Domains []Domain `json:"domains"`
|
||||||
IPUrl string `json:"ip_url"`
|
IPUrl string `json:"ip_url"`
|
||||||
|
IPV6Url string `json:"ipv6_url"`
|
||||||
Interval int `json:"interval"`
|
Interval int `json:"interval"`
|
||||||
UserAgent string `json:"user_agent,omitempty"`
|
UserAgent string `json:"user_agent,omitempty"`
|
||||||
LogPath string `json:"log_path"`
|
LogPath string `json:"log_path"`
|
||||||
Socks5Proxy string `json:"socks5_proxy"`
|
Socks5Proxy string `json:"socks5_proxy"`
|
||||||
Notify Notify `json:"notify"`
|
Notify Notify `json:"notify"`
|
||||||
IPInterface string `json:"ip_interface"`
|
IPInterface string `json:"ip_interface"`
|
||||||
//the code is not ready to update AAAA record
|
Mode string `json:"mode"`
|
||||||
//IPType string `json:"ip_type"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadSettings -- Load settings from config file
|
// LoadSettings -- Load settings from config file
|
||||||
|
35
utils.go
35
utils.go
@ -46,6 +46,10 @@ const (
|
|||||||
GOOGLE = "Google"
|
GOOGLE = "Google"
|
||||||
// DUCK for Duck DNS
|
// DUCK for Duck DNS
|
||||||
DUCK = "DuckDNS"
|
DUCK = "DuckDNS"
|
||||||
|
// IPV4 for IPV4 mode
|
||||||
|
IPV4 = "IPV4"
|
||||||
|
// IPV6 for IPV6 mode
|
||||||
|
IPV6 = "IPV6"
|
||||||
)
|
)
|
||||||
|
|
||||||
//GetIPFromInterface gets IP address from the specific interface
|
//GetIPFromInterface gets IP address from the specific interface
|
||||||
@ -84,17 +88,17 @@ func GetIPFromInterface(configuration *Settings) (string, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
//the code is not ready for updating an AAAA record
|
//the code is not ready for updating the 'AAAA' record
|
||||||
/*
|
if isIPv4(ip.String()) {
|
||||||
if (isIPv4(ip.String())){
|
if strings.ToUpper(configuration.Mode) == IPV4 {
|
||||||
if (configuration.IPType=="IPv6"){
|
continue
|
||||||
continue;
|
}
|
||||||
}
|
} else {
|
||||||
}else{
|
if configuration.Mode != IPV6 {
|
||||||
if (configuration.IPType!="IPv6"){
|
continue
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
} */
|
|
||||||
if !isIPv4(ip.String()) {
|
if !isIPv4(ip.String()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -172,7 +176,14 @@ func GetIPOnline(configuration *Settings) (string, error) {
|
|||||||
httpTransport.Dial = dialer.Dial
|
httpTransport.Dial = dialer.Dial
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := client.Get(configuration.IPUrl)
|
var response *http.Response
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if configuration.Mode == IPV4 {
|
||||||
|
response, err = client.Get(configuration.IPUrl)
|
||||||
|
} else {
|
||||||
|
response, err = client.Get(configuration.IPV6Url)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Cannot get IP...")
|
log.Println("Cannot get IP...")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user