packages feed

ip2location 8.5.0 → 8.5.1

raw patch · 5 files changed

+51/−34 lines, 5 filesdep ~aesondep ~basedep ~bytestring

Dependency ranges changed: aeson, base, bytestring, http-client, split

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for ip2location +## 8.5.1  -- 2024-12-04++* Fixed boundary cases. Fixed IPv6 address error when using IPv4 BIN.++ ## 8.5.0  -- 2023-04-11  * Added support for district, ASN and AS.
IP2Location.hs view
@@ -1,7 +1,7 @@ {-|
 Module      : IP2Location
 Description : IP2Location Haskell package
-Copyright   : (c) IP2Location, 2023
+Copyright   : (c) IP2Location, 2023 - 2024
 License     : MIT
 Maintainer  : sales@ip2location.com
 Stability   : experimental
@@ -143,7 +143,7 @@     The 'getAPIVersion' function returns a string containing the API version.
 -}
 getAPIVersion :: String
-getAPIVersion = "8.5.0"
+getAPIVersion = "8.5.1"
 
 ipToOcts :: IP -> [Int]
 ipToOcts (IPv4 ip) = fromIPv4 ip
@@ -356,25 +356,33 @@         
 search4 :: BS.ByteString -> Integer -> Int -> Int -> Int -> Int -> Int -> Int -> IP2LocationRecord
 search4 contents ipnum dbtype low high baseaddr indexbaseaddr colsize = do
+    let ipnum2 = if (ipnum == 4294967295)
+        then ipnum - 1
+        else ipnum
+    
     if indexbaseaddr > 0
         then do
-            let indexpos = fromIntegral (((ipnum `rotateR` 16) `rotateL` 3) + (toInteger indexbaseaddr))
+            let indexpos = fromIntegral (((ipnum2 `rotateR` 16) `rotateL` 3) + (toInteger indexbaseaddr))
             let low2 = readuint32 contents indexpos
             let high2 = readuint32 contents (indexpos + 4)
-            searchtree contents ipnum dbtype low2 high2 baseaddr colsize 4
+            searchtree contents ipnum2 dbtype low2 high2 baseaddr colsize 4
         else
-            searchtree contents ipnum dbtype low high baseaddr colsize 4
+            searchtree contents ipnum2 dbtype low high baseaddr colsize 4
 
 search6 :: BS.ByteString -> Integer -> Int -> Int -> Int -> Int -> Int -> Int -> IP2LocationRecord
 search6 contents ipnum dbtype low high baseaddr indexbaseaddr colsize = do
+    let ipnum2 = if (ipnum == 340282366920938463463374607431768211455)
+        then ipnum - 1
+        else ipnum
+    
     if indexbaseaddr > 0
         then do
-            let indexpos = fromIntegral (((ipnum `rotateR` 112) `rotateL` 3) + (toInteger indexbaseaddr))
+            let indexpos = fromIntegral (((ipnum2 `rotateR` 112) `rotateL` 3) + (toInteger indexbaseaddr))
             let low2 = readuint32 contents indexpos
             let high2 = readuint32 contents (indexpos + 4)
-            searchtree contents ipnum dbtype low2 high2 baseaddr colsize 6
+            searchtree contents ipnum2 dbtype low2 high2 baseaddr colsize 6
         else
-            searchtree contents ipnum dbtype low high baseaddr colsize 6
+            searchtree contents ipnum2 dbtype low high baseaddr colsize 6
 
 tryfirst myIP = do
     result <- try (evaluate (ipStringToInteger myIP)) :: IO (Either SomeException Integer)
@@ -416,5 +424,9 @@                     else if ipnum >= fromV4Compatible && ipnum <= toV4Compatible
                         then do
                             return $ search4 contents ipnum (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta)
-                        else do
-                            return $ search6 contents ipnum (databasetype meta) 0 (ipv6databasecount meta) (ipv6databaseaddr meta) (ipv6indexbaseaddr meta) (ipv6columnsize meta)
+                        else if (ipv6databasecount meta) == 0
+                            then do
+                                let x = "IPv6 address missing in IPv4 BIN."
+                                return $ IP2LocationRecord x x x x x 0.0 0.0 x x x x x x x x x x x 0.0 x x x x x x
+                            else do
+                                return $ search6 contents ipnum (databasetype meta) 0 (ipv6databasecount meta) (ipv6databaseaddr meta) (ipv6indexbaseaddr meta) (ipv6columnsize meta)
IP2LocationWebService.hs view
@@ -2,7 +2,7 @@ {-|
 Module      : IP2LocationWebService
 Description : IP2Location Haskell package
-Copyright   : (c) IP2Location, 2023
+Copyright   : (c) IP2Location, 2023 - 2024
 License     : MIT
 Maintainer  : sales@ip2location.com
 Stability   : experimental
LICENSE view
@@ -1,21 +1,21 @@-MIT License
-
-Copyright (c) 2023 IP2Location.com
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+MIT License++Copyright (c) 2023 - 2024 IP2Location.com++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
ip2location.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             8.5.0+version:             8.5.1  -- A short (one-line) description of the package. synopsis:            IP2Location Haskell package for IP geolocation.@@ -60,7 +60,7 @@   -- other-extensions:          -- Other library packages from which modules are imported.-  build-depends:       base >=4.9 && <=4.18, bytestring >=0.10 && <0.12, binary >=0.8.4 && <0.9, iproute >=1.7 && <1.8, aeson >=1.5 && <1.6, http-types >=0.12 && <0.13, http-client >=0.6 && <0.7, http-client-tls >=0.3 && <0.4, uri-encode >=1.5 && <1.6, split <=0.2.3.4+  build-depends:       base >=4.9 && <=4.21, bytestring >=0.10 && <0.13, binary >=0.8.4 && <0.9, iproute >=1.7 && <1.8, aeson >=1.5 && <2.3, http-types >=0.12 && <0.13, http-client >=0.6 && <0.8, http-client-tls >=0.3 && <0.4, uri-encode >=1.5 && <1.6, split <=0.2.5      -- Directories containing source files.   -- hs-source-dirs: