static PyObject * GeoIP_country_code_by_addr_v6_Py(PyObject *self, PyObject *args) { char * name; const char * retval; GeoIP_GeoIPObject* GeoIP = (GeoIP_GeoIPObject*)self; if (!PyArg_ParseTuple(args, "s", &name)) { return NULL; } retval = GeoIP_country_code_by_addr_v6(GeoIP->gi, name); return Py_BuildValue("s", retval); }
std::string* SetExt(User* user) { const char* code = NULL; switch (user->client_sa.family()) { case AF_INET: code = GeoIP_country_code_by_addr(ipv4db, user->GetIPString().c_str()); break; case AF_INET6: code = GeoIP_country_code_by_addr_v6(ipv6db, user->GetIPString().c_str()); break; } ext.set(user, code ? code : "UNK"); return ext.get(user); }
/*@null@*/ const char *getcountrybyaddr6( char *address, char *geoip_data_file ) { const char *country_code = NULL; char *data_file; GeoIP *gi; /* set the data file */ data_file = ( geoip_data_file != NULL ) ? geoip_data_file : GEOIP6_DAT; /* open the GeoIP database */ gi = GeoIP_open( data_file, GEOIP_STANDARD ); if ( gi != NULL ) { /* Get the Country Code for the address */ country_code = GeoIP_country_code_by_addr_v6( gi, address ); /* close the GeoIP database */ GeoIP_delete( gi ); } /*@-mustfreefresh@*/ return( country_code ); /*@+mustfreefresh@*/ }