mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-12-22 23:28:01 +00:00
35 lines
470 B
Go
35 lines
470 B
Go
|
package service
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net"
|
||
|
|
||
|
"github.com/dcarrillo/whatismyip/models"
|
||
|
)
|
||
|
|
||
|
type Geo struct {
|
||
|
IP net.IP
|
||
|
}
|
||
|
|
||
|
func (g *Geo) LookUpCity() *models.GeoRecord {
|
||
|
record := &models.GeoRecord{}
|
||
|
err := record.LookUp(g.IP)
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
return record
|
||
|
}
|
||
|
|
||
|
func (g *Geo) LookUpASN() *models.ASNRecord {
|
||
|
record := &models.ASNRecord{}
|
||
|
err := record.LookUp(g.IP)
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
return record
|
||
|
}
|