gofmt -- hopefuly what works

This commit is contained in:
Ethan Knowlton 2023-09-22 21:28:49 -04:00
parent 02619025af
commit 79e3d6a9be
6 changed files with 67 additions and 68 deletions

View File

@ -55,7 +55,7 @@ func main() {
}
var parser parser.Parser
if (*service == "geoip") {
if *service == "geoip" {
geo, err := geo.Open(*countryFile, *cityFile, *asnFile)
if err != nil {
log.Fatal(err)
@ -63,7 +63,7 @@ func main() {
parser = &geo
}
if (*service == "ipstack") {
if *service == "ipstack" {
if err := ipstackApi.Init(ipstackApiKey); err != nil {
log.Fatal(err)
}

View File

@ -172,8 +172,7 @@
<p>
This information is provided from the GeoLite2 database created by
MaxMind, available from
<a href="https://www.maxmind.com">www.maxmind.com</a>
</p>
<a href="https://www.maxmind.com">www.maxmind.com</a> </p>
{{ end}} {{ if .Service == "ipstack" }}
<p>
This information is provided from

View File

@ -81,7 +81,8 @@ func (g *geoip) Parse(ip net.IP, hostname string) (parser.Response, error) {
autonomousSystemNumber = fmt.Sprintf("AS%d", asn.AutonomousSystemNumber)
}
return parser.Response{
Service: "ipstack",
UsingGeoIP: true,
UsingIPStack: false,
IP: ip,
IPDecimal: ipDecimal,
Country: country.Name,

View File

@ -14,20 +14,18 @@ type IPStack struct {
}
func (ips *IPStack) Parse(ip net.IP, hostname string) (parser.Response, error) {
res, err := ipstack.IP(ip.String());
res, err := ipstack.IP(ip.String())
ips.response = res
if err != nil {
return parser.Response{}, err
}
fmt.Printf("%+v\n", res)
ipDecimal := iputil.ToDecimal(ip)
parserResponse := parser.Response{
Service: "ipstack",
UsingGeoIP: false,
UsingIPStack: true,
Latitude: float64(res.Latitide),
Longitude: float64(res.Longitude),
Hostname: hostname,
@ -47,7 +45,7 @@ func (ips *IPStack) Parse(ip net.IP, hostname string) (parser.Response, error) {
}
if res.Location != nil {
parserResponse.CountryEU = &res.Location.IsEU;
parserResponse.CountryEU = &res.Location.IsEU
}
if res.Connection != nil {

View File

@ -13,7 +13,8 @@ type Parser interface {
}
type Response struct {
Service string `json:"database"`
UsingGeoIP bool `json:"UsingGeoIP"`
UsingIPStack bool `json:"UsingIPStack"`
IP net.IP `json:"ip"`
IPDecimal *big.Int `json:"ip_decimal"`
Country string `json:"country,omitempty"`