hotfix(publicip): revert back JSON to public_ip
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user