geoip

GeoIP table join with table of IP's in MySQL

社会主义新天地 提交于 2019-11-30 14:35:53
I am having a issue finding a fast way of joining the tables looking like that: mysql> explain geo_ip; +--------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------+-------+ | ip_start | varchar(32) | NO | | "" | | | ip_end | varchar(32) | NO | | "" | | | ip_num_start | int(64) unsigned | NO | PRI | 0 | | | ip_num_end | int(64) unsigned | NO | | 0 | | | country_code | varchar(3) | NO | | "" | | | country_name | varchar(64) | NO | | "" | | | ip_poly | geometry | NO | MUL | NULL | | +--

Importing MaxMind's GeoLite2 to MySQL

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 05:52:56
问题 MaxMind's GeoLite2 is a wonderful database and is very useful if you want to map IP addresses to countries . To do this efficiently, I want to import it into a MySQL database with a scheme like this: I remember writing an import script for the CSV database long time ago, but the CSV as you can download it today has a very difficult to understand format, at least to me: network,geoname_id,registered_country_geoname_id,represented_country_geoname_id,is_anonymous_proxy,is_satellite_provider 1.0

Geoip2's python library doesn't work in pySpark's map function

二次信任 提交于 2019-11-30 03:44:56
问题 I'm using geoip2's python library and pySpark to get the geographical address of some IPs. My code is like: geoDBpath = 'somePath/geoDB/GeoLite2-City.mmdb' geoPath = os.path.join(geoDBpath) sc.addFile(geoPath) reader = geoip2.database.Reader(SparkFiles.get(geoPath)) def ip2city(ip): try: city = reader.city(ip).city.name except: city = 'not found' return city I tried print ip2city("128.101.101.101") It works. But when I tried to do this in rdd.map: rdd = sc.parallelize([ip1, ip2, ip3, ip3, ...

docker之Dockerfile实践

佐手、 提交于 2019-11-30 03:08:55
docker之Dockerfile实践 先查看下本地的镜像,选一个作为base image: [root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE wadeson/centos_nginx v1 210a202d37b8 2 hours ago 464MB nginx latest c59f17fe53b0 4 days ago 108MB ubuntu latest 747cb2d60bbe 3 weeks ago 122MB centos latest 196e0ce0c9fb 6 weeks ago 197MB 在某一个目录下面创建一个专门存放此demo的目录,也就是Dockerfile所在的context: [root@docker ~]# mkdir docker_demo [root@docker ~]# cd docker_demo/ [root@docker docker_demo]# touch Dockerfile [root@docker docker_demo]# pwd /root/docker_demo [root@docker docker_demo]# ll total 0 -rw-r--r--. 1 root root 0 Nov 1 04:34 Dockerfile

GeoIp redirect specific country Traffic to country domain?

Deadly 提交于 2019-11-29 12:58:39
I want to redirect US country traffic to my country domain from mydomain.com . My website is in Wordpress and i would prefer .htaccess. i have applied the below code but it redirecting all IP addresses to mydomain.us . Will any body help? GeoIPEnable On RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(US)$ RewriteRule ^(.*)$ http://mydomain.us [R,L] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress My

How to find the geoip location for all users in Nodejs

喜夏-厌秋 提交于 2019-11-29 08:48:17
I have a requirement where i have to find the geoip location of the users. I have used the code where i store the address of the user in database and then display the geoip location of that user.Now suppose the users changed his location to some other place.If the user now logs in from that region or country, how should i display the geoip of that user. The code that i use is: geo.geocoder(geo.google, address, sensor,function(formattedAddress, latitude, longitude) { console.log("Formatted Address: " + formattedAddress); console.log("Latitude: " + latitude); console.log("Longitude: " +

GeoIP定位查询 Java篇

倖福魔咒の 提交于 2019-11-29 08:28:44
GeoIP数据库下载地址:http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz API 源码下载 http://geolite.maxmind.com/download/geoip/api/java/ 下载解压:有一些测试类 “*test.java”,如 CountryLookupTest.java 将所有源码拷贝在一个java工程下面... 改下源码的Geoip.dat文件的目录 :我是放在C盘; 代码: class CountryLookupTest { public static void main(String[] args) { try { // String sep = System.getProperty("file.separator"); // // // Uncomment for windows // String dir = System.getProperty("user.dir"); // // // Uncomment for Linux // //String dir = "/usr/local/share/GeoIP"; // // String dbfile = dir + sep + "GeoIP.dat"; // You should

Cache JSON response

送分小仙女□ 提交于 2019-11-29 02:38:49
I using some GeoIP service to place country flag on pages depends on country IP. And I need to cache JSON response for all pages on my site. This code placed into header.php : $.getJSON('http://smart-ip.net/geoip-json?callback=?', function(data) { $('#flag').html("<a class='fancybox-inline int' href='#international'><img src='/images/flags/"+data.countryCode+".png'></a>"); } Is it possible to cache it with $.ajaxSetup({ cache: true }) ? - seems to not work. Or probably better to use HTML5 localStorage, but I'm not sure how to do that. I also tried JSONCache plugin, but it did not work for me.

Importing MaxMind's GeoLite2 to MySQL

本秂侑毒 提交于 2019-11-28 01:45:10
MaxMind's GeoLite2 is a wonderful database and is very useful if you want to map IP addresses to countries . To do this efficiently, I want to import it into a MySQL database with a scheme like this: I remember writing an import script for the CSV database long time ago, but the CSV as you can download it today has a very difficult to understand format, at least to me: network,geoname_id,registered_country_geoname_id,represented_country_geoname_id,is_anonymous_proxy,is_satellite_provider 1.0.0.0/24,2077456,2077456,,0,0 1.0.1.0/24,1814991,1814991,,0,0 1.0.2.0/23,1814991,1814991,,0,0 1.0.4.0/22

How to improve performance of GeoIP query in BigQuery?

微笑、不失礼 提交于 2019-11-27 12:55:04
I have loaded my application logs in BigQuery and I need to calculate country based on IP address from those logs. I have written a join query between my table and a GeoIP mapping table that I downloaded from MaxMind . An ideal query would be OUTER JOIN with range filter, however BQ supports only = in join conditions. So the query does an INNER JOIN and handles missing values in each side of the JOIN . I have amended my original query so it could run on the Wikipedia public data set. Can someone please help me make this run faster? SELECT id, client_ip, client_ip_code, B.Country_Name as