]> gitweb.factorcode.org Git - factor.git/commitdiff
geo-ip: change to use ip-parser for ipv4 lookup.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 9 Feb 2014 19:00:38 +0000 (11:00 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 9 Feb 2014 19:00:38 +0000 (11:00 -0800)
extra/geo-ip/geo-ip.factor

index d63f01aaf232ebf72e60d78c82d139f7085e92ea..a14d9335ef2e8c3ca2eed2f8baf44c4b55bec52c 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs combinators combinators.smart
-csv grouping http.client interval-maps io.encodings.ascii
-io.files io.files.temp io.launcher io.pathnames kernel math
-math.parser math.vectors memoize sequences splitting strings ;
+USING: accessors arrays assocs combinators combinators.smart csv
+grouping http.client interval-maps io.encodings.ascii io.files
+io.files.temp io.launcher io.pathnames ip-parser kernel math
+math.parser memoize sequences strings ;
 IN: geo-ip
 
 : db-path ( -- path ) "IpToCountry.csv" cache-file ;
@@ -47,9 +47,6 @@ MEMO: ip-intervals ( -- interval-map )
 
 GENERIC: lookup-ip ( ip -- ip-entry )
 
-M: string lookup-ip
-    "." split [ string>number ] map
-    { 0x1000000 0x10000 0x100 0x1 } v.
-    lookup-ip ;
+M: string lookup-ip ipv4-aton lookup-ip ;
 
 M: integer lookup-ip ip-intervals interval-at ;