Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addrtools public IP provider #889

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ You can otherwise customize it with the following:
- `wtfismyip` using [https://wtfismyip.com/text](https://wtfismyip.com/text)
- `seeip` using [https://api.seeip.org](https://api.seeip.org)
- `changeip` using [https://ip.changeip.com](https://ip.changeip.com)
- `addrtools` using [https://myip.addr.tools](https://myip.addr.tools)
- You can also specify an HTTPS URL with prefix `url:` for example `url: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 @@ -334,6 +335,7 @@ You can otherwise customize it with the following:
- `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)
- `addrtools` using [https://myipv4.addr.tools](https://myipv4.addr.tools)
- You can also specify an HTTPS URL with prefix `url:` for example `url: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 @@ -343,6 +345,7 @@ You can otherwise customize it with the following:
- `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)
- `addrtools` using [https://myipv6.addr.tools](https://myipv6.addr.tools)
- You can also specify an HTTPS URL with prefix `url:` for example `url: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
8 changes: 8 additions & 0 deletions pkg/publicip/http/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
Wtfismyip Provider = "wtfismyip"
Seeip Provider = "seeip"
Changeip Provider = "changeip"
Addrtools Provider = "addrtools"
)

func ListProviders() []Provider {
Expand All @@ -38,6 +39,7 @@ func ListProviders() []Provider {
Wtfismyip,
Seeip,
Changeip,
Addrtools,
}
}

Expand Down Expand Up @@ -92,6 +94,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ipv4.wtfismyip.com/text"
case Seeip:
url = "https://ipv4.seeip.org"
case Addrtools:
url = "https://myipv4.addr.tools"
}

case ipversion.IP6:
Expand All @@ -110,6 +114,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://ipv6.wtfismyip.com/text"
case Seeip:
url = "https://ipv6.seeip.org"
case Addrtools:
url = "https://myipv6.addr.tools"
}

case ipversion.IP4or6:
Expand All @@ -136,6 +142,8 @@ func (provider Provider) url(version ipversion.IPVersion) (url string, ok bool)
url = "https://api.seeip.org"
case Changeip:
url = "https://ip.changeip.com"
case Addrtools:
url = "https://myip.addr.tools"
}
}

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

Expand Down
Loading