feat(publicip/http): add multiple providers for all IP versions

- icanhazip
- ident
- nnev
- wtfismyip
This commit is contained in:
Quentin McGaw
2024-02-12 14:27:57 +00:00
parent d009ef3d3e
commit 5e0e3f4702
4 changed files with 56 additions and 11 deletions

View File

@@ -22,7 +22,7 @@
"pattern": "https://www.linode.com/docs/products/tools/api/guides/manage-api-tokens/"
},
{
"pattern": "https://ipv6.ipleak.net/json"
"pattern": "https://(ip|ipv|v)6.+"
},
{
"pattern": "https://github.com/qdm12/ddns-updater/pkgs/container/ddns-updater"

View File

@@ -277,14 +277,26 @@ You can otherwise customize it with the following:
- `google` using [https://domains.google.com/checkip](https://domains.google.com/checkip)
- `spdyn` using [https://checkip.spdyn.de](https://checkip.spdyn.de/)
- `ipleak` using [https://ipleak.net/json](https://ipleak.net/json)
- `icanhazip` using [https://icanhazip.com](https://icanhazip.com)
- `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)
- 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)
- `ipify` using [https://api.ipify.org](https://api.ipify.org)
- `icanhazip` using [https://ipv4.icanhazip.com](https://ipv4.icanhazip.com)
- `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)
- 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)
- `ipify` using [https://api6.ipify.org](https://api6.ipify.org)
- `icanhazip` using [https://ipv6.icanhazip.com](https://ipv6.icanhazip.com)
- `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)
- 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`

View File

@@ -12,12 +12,16 @@ import (
type Provider string
const (
Google Provider = "google"
Ifconfig Provider = "ifconfig"
Ipify Provider = "ipify"
Ipinfo Provider = "ipinfo"
Spdyn Provider = "spdyn"
Ipleak Provider = "ipleak"
Google Provider = "google"
Ifconfig Provider = "ifconfig"
Ipify Provider = "ipify"
Ipinfo Provider = "ipinfo"
Spdyn Provider = "spdyn"
Ipleak Provider = "ipleak"
Icanhazip Provider = "icanhazip"
Ident Provider = "ident"
Nnev Provider = "nnev"
Wtfismyip Provider = "wtfismyip"
)
func ListProviders() []Provider {
@@ -28,6 +32,10 @@ func ListProviders() []Provider {
Ipinfo,
Spdyn,
Ipleak,
Icanhazip,
Ident,
Nnev,
Wtfismyip,
}
}
@@ -72,6 +80,14 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://api.ipify.org"
case Ipleak:
url = "https://ipv4.ipleak.net/json"
case Icanhazip:
url = "https://ipv4.icanhazip.com"
case Ident:
url = "https://v4.ident.me"
case Nnev:
url = "https://ip4.nnev.de"
case Wtfismyip:
url = "https://ipv4.wtfismyip.com/text"
}
case ipversion.IP6:
@@ -80,6 +96,14 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://api6.ipify.org"
case Ipleak:
url = "https://ipv6.ipleak.net/json"
case Icanhazip:
url = "https://ipv6.icanhazip.com"
case Ident:
url = "https://v6.ident.me"
case Nnev:
url = "https://ip6.nnev.de"
case Wtfismyip:
url = "https://ipv6.wtfismyip.com/text"
}
case ipversion.IP4or6:
@@ -96,6 +120,14 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://checkip.spdyn.de"
case Ipleak:
url = "https://ipleak.net/json"
case Icanhazip:
url = "https://icanhazip.com"
case Ident:
url = "https://ident.me"
case Nnev:
url = "https://ip.nnev.de"
case Wtfismyip:
url = "https://wtfismyip.com/text"
}
}

View File

@@ -18,16 +18,17 @@ func Test_ListProvidersForVersion(t *testing.T) {
providers []Provider
}{
"ip4or6": {
version: ipversion.IP4or6,
providers: []Provider{Google, Ifconfig, Ipify, Ipinfo, Spdyn, Ipleak},
version: ipversion.IP4or6,
providers: []Provider{Google, Ifconfig, Ipify, Ipinfo, Spdyn, Ipleak,
Icanhazip, Ident, Nnev, Wtfismyip},
},
"ip4": {
version: ipversion.IP4,
providers: []Provider{Ipify, Ipleak},
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip},
},
"ip6": {
version: ipversion.IP6,
providers: []Provider{Ipify, Ipleak},
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip},
},
}