Skip to content

Commit

Permalink
feat(publicip/http): add seeip.org for all ip versions
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Feb 13, 2024
1 parent 5e0e3f4 commit 346f4aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ You can otherwise customize it with the following:
- `ident` using [https://ident.me](https://ident.me)
- `nnev` using [https://ip.nnev.de](https://ip.nnev.de)
- `wtfismyip` using [https://wtfismyip.com/text](https://wtfismyip.com/text)
- `seeip` using [https://api.seeip.org](https://api.seeip.org)
- You can also specify an HTTPS URL such as `https://ipinfo.io/ip`
- `PUBLICIPV4_HTTP_PROVIDERS` gets your public IPv4 address only. It can be one or more of the following:
- `ipleak` using [https://ipv4.ipleak.net/json](https://ipv4.ipleak.net/json)
Expand All @@ -289,6 +290,7 @@ You can otherwise customize it with the following:
- `ident` using [https://v4.ident.me](https://v4.ident.me)
- `nnev` using [https://ip4.nnev.de](https://ip4.nnev.de)
- `wtfismyip` using [https://ipv4.wtfismyip.com/text](https://ipv4.wtfismyip.com/text)
- `seeip` using [https://ipv4.seeip.org](https://ipv4.seeip.org)
- You can also specify an HTTPS URL such as `https://ipinfo.io/ip`
- `PUBLICIPV6_HTTP_PROVIDERS` gets your public IPv6 address only. It can be one or more of the following:
- `ipleak` using [https://ipv6.ipleak.net/json](https://ipv6.ipleak.net/json)
Expand All @@ -297,6 +299,7 @@ You can otherwise customize it with the following:
- `ident` using [https://v6.ident.me](https://v6.ident.me)
- `nnev` using [https://ip6.nnev.de](https://ip6.nnev.de)
- `wtfismyip` using [https://ipv6.wtfismyip.com/text](https://ipv6.wtfismyip.com/text)
- `seeip` using [https://ipv6.seeip.org](https://ipv6.seeip.org)
- You can also specify an HTTPS URL such as `https://ipinfo.io/ip`
- `PUBLICIP_DNS_PROVIDERS` gets your public IPv4 address only or IPv6 address only or one of them (see #136). It can be one or more of the following:
- `cloudflare`
Expand Down
10 changes: 9 additions & 1 deletion pkg/publicip/http/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
Ident Provider = "ident"
Nnev Provider = "nnev"
Wtfismyip Provider = "wtfismyip"
Seeip Provider = "seeip"
)

func ListProviders() []Provider {
Expand All @@ -36,6 +37,7 @@ func ListProviders() []Provider {
Ident,
Nnev,
Wtfismyip,
Seeip,
}
}

Expand Down Expand Up @@ -72,7 +74,7 @@ func ValidateProvider(provider Provider, version ipversion.IPVersion) error {
return fmt.Errorf("%w: %s", ErrUnknownProvider, provider)
}

func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool) {
func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool) { //nolint:gocyclo
switch version {
case ipversion.IP4:
switch provider { //nolint:exhaustive
Expand All @@ -88,6 +90,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ip4.nnev.de"
case Wtfismyip:
url = "https://ipv4.wtfismyip.com/text"
case Seeip:
url = "https://ipv4.seeip.org"
}

case ipversion.IP6:
Expand All @@ -104,6 +108,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ip6.nnev.de"
case Wtfismyip:
url = "https://ipv6.wtfismyip.com/text"
case Seeip:
url = "https://ipv6.seeip.org"
}

case ipversion.IP4or6:
Expand All @@ -128,6 +134,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ip.nnev.de"
case Wtfismyip:
url = "https://wtfismyip.com/text"
case Seeip:
url = "https://api.seeip.org"
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/publicip/http/providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func Test_ListProvidersForVersion(t *testing.T) {
"ip4or6": {
version: ipversion.IP4or6,
providers: []Provider{Google, Ifconfig, Ipify, Ipinfo, Spdyn, Ipleak,
Icanhazip, Ident, Nnev, Wtfismyip},
Icanhazip, Ident, Nnev, Wtfismyip, Seeip},
},
"ip4": {
version: ipversion.IP4,
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip},
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip, Seeip},
},
"ip6": {
version: ipversion.IP6,
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip},
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip, Seeip},
},
}

Expand Down

0 comments on commit 346f4aa

Please sign in to comment.