@@ -24,18 +24,20 @@ You can query the geolocation information from the IP2Proxy BIN database as belo
2424
2525``` haskell
2626import IP2Proxy
27+ import qualified Data.ByteString.Lazy as BS
2728
2829main :: IO ()
2930main = do
3031 let myfile = " ./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE.BIN"
3132 let ip = " 197.85.191.64"
32- meta <- open myfile
33+ contents <- BS. readFile myfile -- load BIN once
34+ meta <- openBS contents
3335
3436 putStrLn $ " module_version: " ++ getModuleVersion
3537 putStrLn $ " package_version: " ++ (getPackageVersion meta)
3638 putStrLn $ " database_version: " ++ (getDatabaseVersion meta)
3739
38- result <- getAll myfile meta ip
40+ result <- getAllBS contents meta ip
3941 putStrLn $ " country_short: " ++ (show (country_short result))
4042 putStrLn $ " country_long: " ++ (show (country_long result))
4143 putStrLn $ " region: " ++ (show (region result))
@@ -52,34 +54,34 @@ main = do
5254 putStrLn $ " fraud_score: " ++ (show (fraud_score result))
5355 putStrLn $ " is_proxy: " ++ (show (is_proxy result))
5456
55- result <- getCountryShort myfile meta ip
57+ result <- getCountryShortBS contents meta ip
5658 putStrLn $ " country_short: " ++ result
57- result <- getCountryLong myfile meta ip
59+ result <- getCountryLongBS contents meta ip
5860 putStrLn $ " country_long: " ++ result
59- result <- getRegion myfile meta ip
61+ result <- getRegionBS contents meta ip
6062 putStrLn $ " region: " ++ result
61- result <- getCity myfile meta ip
63+ result <- getCityBS contents meta ip
6264 putStrLn $ " city: " ++ result
63- result <- getISP myfile meta ip
65+ result <- getISPBS contents meta ip
6466 putStrLn $ " isp: " ++ result
65- result <- getProxyType myfile meta ip
67+ result <- getProxyTypeBS contents meta ip
6668 putStrLn $ " proxy_type: " ++ result
67- result <- getDomain myfile meta ip
69+ result <- getDomainBS contents meta ip
6870 putStrLn $ " domain: " ++ result
69- result <- getUsageType myfile meta ip
71+ result <- getUsageTypeBS contents meta ip
7072 putStrLn $ " usage_type: " ++ result
71- result <- getASN myfile meta ip
73+ result <- getASNBS contents meta ip
7274 putStrLn $ " asn: " ++ result
73- result <- getAS myfile meta ip
75+ result <- getASBS contents meta ip
7476 putStrLn $ " as: " ++ result
75- result <- getLastSeen myfile meta ip
77+ result <- getLastSeenBS contents meta ip
7678 putStrLn $ " last_seen: " ++ result
77- result <- getThreat myfile meta ip
79+ result <- getThreatBS contents meta ip
7880 putStrLn $ " threat: " ++ result
79- result <- getProvider myfile meta ip
81+ result <- getProviderBS contents meta ip
8082 putStrLn $ " provider: " ++ result
81- result <- getFraudScore myfile meta ip
83+ result <- getFraudScoreBS contents meta ip
8284 putStrLn $ " fraud_score: " ++ result
83- result <- isProxy myfile meta ip
85+ result <- isProxyBS contents meta ip
8486 putStrLn $ " is_proxy: " ++ result
8587```
0 commit comments