hotfix(publicip): revert back JSON to public_ip

This commit is contained in:
Quentin McGaw
2022-06-25 15:52:00 +00:00
parent 62ad8bcd8f
commit 037f19e852
9 changed files with 66 additions and 23 deletions

View File

@@ -1,6 +1,10 @@
package ipinfo
import "net"
import (
"net"
"github.com/qdm12/gluetun/internal/models"
)
type Response struct {
IP net.IP `json:"ip,omitempty"`
@@ -14,9 +18,18 @@ type Response struct {
Timezone string `json:"timezone,omitempty"`
}
func (r Response) Copy() (copied Response) {
copied = r
copied.IP = make(net.IP, len(r.IP))
copy(copied.IP, r.IP)
return copied
func (r *Response) ToPublicIPModel() (model models.PublicIP) {
model = models.PublicIP{
IP: make(net.IP, len(r.IP)),
Region: r.Region,
Country: r.Country,
City: r.City,
Hostname: r.Hostname,
Location: r.Loc,
Organization: r.Org,
PostalCode: r.Postal,
Timezone: r.Timezone,
}
copy(model.IP, r.IP)
return model
}