mirror of
https://gitlab.com/pnx-tools/dns-updater.git
synced 2026-06-16 05:54:56 +02:00
Adding ip/resolver/jsonip.go
This commit is contained in:
parent
7b916ce09e
commit
b2232a8fa7
1 changed files with 20 additions and 0 deletions
20
ip/resolver/jsonip.go
Normal file
20
ip/resolver/jsonip.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package resolver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
func JsonipDecoder(r io.Reader) ([]byte, error) {
|
||||
var v struct {
|
||||
Ip string `json:"ip"`
|
||||
Location string `json:"geo-ip"`
|
||||
Help string `json:"API Help"`
|
||||
}
|
||||
var val []byte
|
||||
err := json.NewDecoder(r).Decode(&v)
|
||||
if err == nil {
|
||||
val = []byte(v.Ip)
|
||||
}
|
||||
return val, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue