1
0
Fork 0
mirror of https://gitlab.com/pnx-tools/dns-updater.git synced 2026-06-16 05:54:56 +02:00

ip/resolver: add some more resolvers

This commit is contained in:
Henrik Hautakoski 2025-10-16 23:11:02 +02:00
parent 534b0d0bbc
commit 7c2ad9384b
2 changed files with 31 additions and 0 deletions

View file

@ -50,4 +50,15 @@ func init() {
ServiceName: "icanhazip",
Url: "https://icanhazip.com",
})
Provide(&httpres.Service{
ServiceName: "ipify",
Url: "https://api.ipify.org",
})
Provide(&httpres.Service{
ServiceName: "myip",
Url: "https://api.myip.com",
Decoder: MyIPDecoder,
})
}

20
ip/resolver/myip.go Normal file
View file

@ -0,0 +1,20 @@
package resolver
import (
"encoding/json"
"io"
)
func MyIPDecoder(r io.Reader) ([]byte, error) {
var v struct {
Ip string `json:"ip"`
Country string `json:"country"`
Cc string `json:"cc"`
}
var val []byte
err := json.NewDecoder(r).Decode(&v)
if err == nil {
val = []byte(v.Ip)
}
return val, err
}