fix(publicip/http): remove opendns option

This commit is contained in:
Quentin McGaw
2023-06-13 14:35:52 +00:00
parent c12b7e50d7
commit baacd052ce
7 changed files with 22 additions and 16 deletions

View File

@@ -39,7 +39,7 @@ func Test_New(t *testing.T) {
},
"with options": {
options: []Option{
SetProvidersIP(Opendns),
SetProvidersIP(Google),
SetProvidersIP4(Ipify),
SetProvidersIP6(Ipify),
SetTimeout(time.Second),
@@ -49,7 +49,7 @@ func Test_New(t *testing.T) {
timeout: time.Second,
ip4or6: &urlsRing{
banned: map[int]string{},
urls: []string{"https://diagnostic.opendns.com/myip"},
urls: []string{"https://domains.google.com/checkip"},
},
ip4: &urlsRing{
banned: map[int]string{},

View File

@@ -1,3 +1,4 @@
//go:build integration
// +build integration
package http
@@ -16,7 +17,7 @@ func Test_integration(t *testing.T) {
client := &http.Client{}
fetcher, err := New(client, SetProvidersIP(Opendns))
fetcher, err := New(client, SetProvidersIP(Google))
require.NoError(t, err)
ctx := context.Background()

View File

@@ -31,7 +31,7 @@ func Test_SetProvidersIP(t *testing.T) {
}{
"Google": {
initialSettings: settings{
providersIP: []Provider{Opendns},
providersIP: []Provider{Ifconfig},
},
providers: []Provider{Google},
expectedSettings: settings{
@@ -40,11 +40,11 @@ func Test_SetProvidersIP(t *testing.T) {
},
"bad provider for IP version": {
initialSettings: settings{
providersIP: []Provider{Opendns},
providersIP: []Provider{Ifconfig},
},
providers: []Provider{Noip},
expectedSettings: settings{
providersIP: []Provider{Opendns},
providersIP: []Provider{Ifconfig},
},
err: errors.New(`provider does not support IP version: "noip" for version ipv4 or ipv6`),
},
@@ -94,11 +94,11 @@ func Test_SetProvidersIP4(t *testing.T) {
initialSettings: settings{
providersIP4: []Provider{Ipify},
},
providers: []Provider{Opendns},
providers: []Provider{Ifconfig},
expectedSettings: settings{
providersIP4: []Provider{Ipify},
},
err: errors.New(`provider does not support IP version: "opendns" for version ipv4`),
err: errors.New(`provider does not support IP version: "ifconfig" for version ipv4`),
},
}
@@ -146,11 +146,11 @@ func Test_SetProvidersIP6(t *testing.T) {
initialSettings: settings{
providersIP6: []Provider{Ipify},
},
providers: []Provider{Opendns},
providers: []Provider{Ifconfig},
expectedSettings: settings{
providersIP6: []Provider{Ipify},
},
err: errors.New(`provider does not support IP version: "opendns" for version ipv6`),
err: errors.New(`provider does not support IP version: "ifconfig" for version ipv6`),
},
}

View File

@@ -17,7 +17,6 @@ const (
Ipify Provider = "ipify"
Ipinfo Provider = "ipinfo"
Noip Provider = "noip"
Opendns Provider = "opendns"
)
func ListProviders() []Provider {
@@ -27,7 +26,6 @@ func ListProviders() []Provider {
Ipify,
Ipinfo,
Noip,
Opendns,
}
}
@@ -90,8 +88,6 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ifconfig.io/ip"
case Ipinfo:
url = "https://ipinfo.io/ip"
case Opendns:
url = "https://diagnostic.opendns.com/myip"
}
}

View File

@@ -19,7 +19,7 @@ func Test_ListProvidersForVersion(t *testing.T) {
}{
"ip4or6": {
version: ipversion.IP4or6,
providers: []Provider{Google, Ifconfig, Ipinfo, Opendns},
providers: []Provider{Google, Ifconfig, Ipinfo},
},
"ip4": {
version: ipversion.IP4,