mirror of
https://gitlab.com/pnx-tools/dns-updater.git
synced 2026-06-16 05:54:56 +02:00
65 lines
1.2 KiB
Go
65 lines
1.2 KiB
Go
package resolver
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"dnsupdater/ip/resolver/decoder"
|
|
httpres "dnsupdater/ip/resolver/http"
|
|
)
|
|
|
|
var services []Service
|
|
|
|
func Provide(service Service) {
|
|
services = append(services, service)
|
|
}
|
|
|
|
func Get(name string) Service {
|
|
for _, service := range services {
|
|
if service.Name() == name {
|
|
return service
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
Provide(&httpres.Service{
|
|
ServiceName: "jsonip",
|
|
Url: "https://jsonip.com",
|
|
Decoder: decoder.Jsonip,
|
|
})
|
|
|
|
Provide(&httpres.Service{
|
|
ServiceName: "ifconfig.me",
|
|
Url: "https://ifconfig.me/ip",
|
|
})
|
|
|
|
Provide(&httpres.Service{
|
|
ServiceName: "ip.me",
|
|
Url: "https://ip.me",
|
|
Headers: http.Header{
|
|
"User-Agent": []string{"curl"},
|
|
},
|
|
})
|
|
|
|
Provide(&httpres.Service{
|
|
ServiceName: "ipecho",
|
|
Url: "http://ipecho.net/plain",
|
|
})
|
|
|
|
Provide(&httpres.Service{
|
|
ServiceName: "icanhazip",
|
|
Url: "https://icanhazip.com",
|
|
})
|
|
|
|
Provide(&httpres.Service{
|
|
ServiceName: "ipify",
|
|
Url: "https://api.ipify.org",
|
|
})
|
|
|
|
Provide(&httpres.Service{
|
|
ServiceName: "myip",
|
|
Url: "https://api.myip.com",
|
|
Decoder: decoder.MyIP,
|
|
})
|
|
}
|