Skip to content

Commit

Permalink
add addrtools public ip http provider
Browse files Browse the repository at this point in the history
  • Loading branch information
brianshea2 committed Dec 24, 2024
1 parent 78f3061 commit bfd0285
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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
13 changes: 10 additions & 3 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},
providers: []Provider{
Ipify, Ipleak, Icanhazip, Ident, Nnev,
Wtfismyip, Seeip, Addrtools,
},
},
"ip6": {
version: ipversion.IP6,
providers: []Provider{Ipify, Ipleak, Icanhazip, Ident, Nnev, Wtfismyip, Seeip},
providers: []Provider{
Ipify, Ipleak, Icanhazip, Ident, Nnev,
Wtfismyip, Seeip, Addrtools,
},
},
}

Expand Down

0 comments on commit bfd0285

Please sign in to comment.