Skip to content

Commit

Permalink
feat(publicip/http): add multiple providers for all IP versions
Browse files Browse the repository at this point in the history
- icanhazip
- ident
- nnev
- wtfismyip
  • Loading branch information
qdm12 committed Feb 12, 2024
1 parent d009ef3 commit bed663a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/configs/mlc-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
40 changes: 34 additions & 6 deletions pkg/publicip/http/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -72,6 +76,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:
Expand All @@ -80,6 +92,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:
Expand All @@ -96,6 +116,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"
}
}

Expand Down

0 comments on commit bed663a

Please sign in to comment.