feat(publicip/http): add Spdyn provider

This commit is contained in:
Quentin McGaw
2024-02-03 08:13:37 +00:00
parent 7b573266e9
commit 2afec6c0ac
3 changed files with 6 additions and 1 deletions

View File

@@ -259,6 +259,7 @@ You can otherwise customize it with the following:
- `ifconfig` using [https://ifconfig.io/ip](https://ifconfig.io/ip) - `ifconfig` using [https://ifconfig.io/ip](https://ifconfig.io/ip)
- `ipinfo` using [https://ipinfo.io/ip](https://ipinfo.io/ip) - `ipinfo` using [https://ipinfo.io/ip](https://ipinfo.io/ip)
- `google` using [https://domains.google.com/checkip](https://domains.google.com/checkip) - `google` using [https://domains.google.com/checkip](https://domains.google.com/checkip)
- `spdyn` using [https://checkip.spdyn.de](https://checkip.spdyn.de/)
- You can also specify an HTTPS URL such as `https://ipinfo.io/ip` - 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: - `PUBLICIPV4_HTTP_PROVIDERS` gets your public IPv4 address only. It can be one or more of the following:
- `ipify` using [https://api.ipify.org](https://api.ipify.org) - `ipify` using [https://api.ipify.org](https://api.ipify.org)

View File

@@ -16,6 +16,7 @@ const (
Ifconfig Provider = "ifconfig" Ifconfig Provider = "ifconfig"
Ipify Provider = "ipify" Ipify Provider = "ipify"
Ipinfo Provider = "ipinfo" Ipinfo Provider = "ipinfo"
Spdyn Provider = "spdyn"
) )
func ListProviders() []Provider { func ListProviders() []Provider {
@@ -24,6 +25,7 @@ func ListProviders() []Provider {
Ifconfig, Ifconfig,
Ipify, Ipify,
Ipinfo, Ipinfo,
Spdyn,
} }
} }
@@ -82,6 +84,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ifconfig.io/ip" url = "https://ifconfig.io/ip"
case Ipinfo: case Ipinfo:
url = "https://ipinfo.io/ip" url = "https://ipinfo.io/ip"
case Spdyn:
url = "https://checkip.spdyn.de"
} }
} }

View File

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