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"`
|
||||
Domains []Domain `json:"domains"`
|
||||
IPUrl string `json:"ip_url"`
|
||||
IPV6Url string `json:"ipv6_url"`
|
||||
Interval int `json:"interval"`
|
||||
UserAgent string `json:"user_agent,omitempty"`
|
||||
LogPath string `json:"log_path"`
|
||||
Socks5Proxy string `json:"socks5_proxy"`
|
||||
Notify Notify `json:"notify"`
|
||||
IPInterface string `json:"ip_interface"`
|
||||
//the code is not ready to update AAAA record
|
||||
//IPType string `json:"ip_type"`
|
||||
Mode string `json:"mode"`
|
||||
}
|
||||
|
||||
// LoadSettings -- Load settings from config file
|
||||
|
35
utils.go
35
utils.go
@ -46,6 +46,10 @@ const (
|
||||
GOOGLE = "Google"
|
||||
// DUCK for Duck DNS
|
||||
DUCK = "DuckDNS"
|
||||
// IPV4 for IPV4 mode
|
||||
IPV4 = "IPV4"
|
||||
// IPV6 for IPV6 mode
|
||||
IPV6 = "IPV6"
|
||||
)
|
||||
|
||||
//GetIPFromInterface gets IP address from the specific interface
|
||||
@ -84,17 +88,17 @@ func GetIPFromInterface(configuration *Settings) (string, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
//the code is not ready for updating an AAAA record
|
||||
/*
|
||||
if (isIPv4(ip.String())){
|
||||
if (configuration.IPType=="IPv6"){
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if (configuration.IPType!="IPv6"){
|
||||
continue;
|
||||
}
|
||||
} */
|
||||
//the code is not ready for updating the 'AAAA' record
|
||||
if isIPv4(ip.String()) {
|
||||
if strings.ToUpper(configuration.Mode) == IPV4 {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if configuration.Mode != IPV6 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if !isIPv4(ip.String()) {
|
||||
continue
|
||||
}
|
||||
@ -172,7 +176,14 @@ func GetIPOnline(configuration *Settings) (string, error) {
|
||||
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 {
|
||||
log.Println("Cannot get IP...")
|
||||
|
Loading…
x
Reference in New Issue
Block a user