6ff8d018525b73c8836fa687bf16f45ccc1a11f1 galt Wed Jun 21 23:33:34 2023 -0700 Adding a utility for using our existing geoIp infrastructure to lookup a 2-letter country code from an IP address (IPv4 or IPv6). Gives an error if the IP address is malformed, gives an error if hgcentral.geoIpCountry6 table does not exist, then uses it to lookup the country. If it is not found in our Maxmind table, then it returns "not found". Hopefully Hiram and others can use this. diff --git src/hg/inc/geoMirror.h src/hg/inc/geoMirror.h index 6fb0546..1a62bb4 100644 --- src/hg/inc/geoMirror.h +++ src/hg/inc/geoMirror.h @@ -2,25 +2,29 @@ /* Copyright (C) 2013 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #ifndef GEOMIRROR_H #define GEOMIRROR_H #include "hdb.h" boolean geoMirrorEnabled(); // return TRUE if this site has geographic mirroring turned on char *geoMirrorNode(); // return which geo mirror node this is (or NULL if geo mirroring is turned off) +char *geoMirrorCountry6(struct sqlConnection *centralConn, char *ipStr); +/* Return 2 letter country code for given IP. user has already checked table geoIpCountry6 exists. + * Return error string otherwise. Free the response string. */ + int geoMirrorDefaultNode(struct sqlConnection *centralConn, char *ipStr); // return default node for given IP char *geoMirrorMenu(); /* Create customized geoMirror menu string for substitution of into * <!-- OPTIONAL_MIRROR_MENU --> in htdocs/inc/globalNavBar.inc * Reads hgcentral geo tables and hg.conf settings. * Free the returned string when done. */ #endif /* GEOMIRROR_H */