On 12.10.2016 13:58, Yuriy M. Kaminskiy wrote:
P.S. ASN/ipv6 change in patch is completely untested (it seems produces
mangled database [as before]).


oops, above ipv6 issue was my patch fault, patch v2 attached, now

$ wget -q http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum2v6.zip && unzip -q GeoIPASNum2v6.zip
$ geoip-generator-asn -6 -o GeoIPASNumv6.dat GeoIPASNum2v6.csv
$ geoiplookup6 -f GeoIPASNumv6.dat www.google.com
GeoIP ASNum V6 Edition: AS15169 Google Inc.
$ geoiplookup6 -f GeoIPASNumv6.dat 2001:67c:1270::
GeoIP ASNum V6 Edition: AS20712

(note: maxmind's original binary GeoIPASNumv6.dat also contains aliases for various mapped ipv4; above generated GeoIPASNumv6.dat contains only native ipv6 addresses)
--- geoip_1.6.7-2~bpo8+1/debian/src/geoip-asn-csv-to-dat.cpp.orig	2016-10-12 12:17:11.000000000 +0300
+++ geoip_1.6.7-2~bpo8+1/debian/src/geoip-asn-csv-to-dat.cpp	2016-10-12 15:41:31.000000000 +0300
@@ -478,9 +478,12 @@
 		for(int i = 0; i<2;++i) {
 			fs = buf.find(delim);
 			fields.push_back(buf.substr(0,fs));
-			buf.erase(0,fs + 1);
+			buf.erase(0,fs + delim.length());
 		}
+		if (buf[0] == '"' || buf[0] == '\'')
 		fields.push_back(buf.substr(1, buf.length() - 2));
+		else
+			fields.push_back(buf);
 	}
 
 	void
@@ -489,13 +492,16 @@
 		std::vector<std::string> & fields)
 	{
 		std::string buf(line);
-		std::string delim = ", ";
+		std::string delim = ",";
 		std::size_t fs;
 		for(int i = 0; i<3;++i) {
 			fs = buf.rfind(delim);
-			fields.push_back(buf.substr(fs+2, buf.length()));
+			fields.push_back(buf.substr(fs+delim.length(), buf.length()));
 			buf.erase(fs,buf.length());
 		}
+		if (buf[0] == '"' || buf[0] == '\'')
+			fields.push_back(buf.substr(1, buf.length() - 2));
+		else
 		fields.push_back(buf.substr(0, buf.length()));
 	}
 
@@ -602,7 +608,7 @@
 						      "Cannot parse maximum address: %s",
 						      csv_fields[V6_CSV_FIELD_MAX_TEXT].c_str());
 				}
-				trie.set_range(minaddr.inetbytes, maxaddr.inetbytes,
+				trie.set_range(minaddr.inet6.s6_addr, maxaddr.inet6.s6_addr,
 					       128, leaf);
 				break;
 

Reply via email to