// Same as GetRecord() but for IPv6. func (gi *GeoIP) GetRecordV6(ip string) *GeoIPRecord { if gi.db == nil { return nil } cip := C.CString(ip) defer C.free(unsafe.Pointer(cip)) gi.mu.Lock() record := C.GeoIP_record_by_addr_v6(gi.db, cip) gi.mu.Unlock() if record == nil { return nil } defer C.GeoIPRecord_delete(record) return populateGeoIPRecords(gi.db.databaseType, record) }
func (gi *GeoIP) RecordByIPv6(ip net.IP) (gir *GeoIPRecord) { cip := checkedCString(ip.String()) defer C.free(unsafe.Pointer(cip)) cGir := C.GeoIP_record_by_addr_v6(gi.gi, cip) if cGir == nil { return nil } // this call frees all the CStrings in cGir defer C.GeoIPRecord_delete(cGir) gir = new(GeoIPRecord) gir.CountryCode = C.GoString(cGir.country_code) gir.CountryCode3 = C.GoString(cGir.country_code3) gir.CountryName = C.GoString(cGir.country_name) gir.Region = C.GoString(cGir.region) gir.City = latin1toUTF8([]byte(C.GoString(cGir.city))) gir.PostalCode = C.GoString(cGir.postal_code) gir.Latitude = float64(cGir.latitude) gir.Longitude = float64(cGir.longitude) gir.AreaCode = int(cGir.area_code) gir.ContinentCode = C.GoString(cGir.continent_code) return }