@@ -99,7 +99,7 @@ getMeta = do
9999 The 'getModuleVersion' function returns a string containing the module version.
100100-}
101101getModuleVersion :: String
102- getModuleVersion = " 2.0 .0"
102+ getModuleVersion = " 2.1 .0"
103103
104104{-|
105105 The 'getPackageVersion' function returns a string containing the package version.
@@ -435,21 +435,32 @@ isProxy myfile meta myip = do
435435doQuery :: String -> Meta -> String -> Int -> IO IP2ProxyRecord
436436doQuery myfile meta myip mode = do
437437 contents <- BS. readFile myfile
438- let from = 281470681743360
439- let to = 281474976710655
440- let fromA = 0
441- let toA = 4294967295
438+ let fromV4Mapped = 281470681743360
439+ let toV4Mapped = 281474976710655
440+ let fromV4Compatible = 0
441+ let toV4Compatible = 4294967295
442+ let from6To4 = 42545680458834377588178886921629466624
443+ let to6To4 = 42550872755692912415807417417958686719
444+ let fromTeredo = 42540488161975842760550356425300246528
445+ let toTeredo = 42540488241204005274814694018844196863
446+ let last32Bits = 4294967295
442447
443448 ipnum <- tryfirst myip
444449 if ipnum == - 1
445450 then do
446451 let x = " INVALID IP ADDRESS"
447452 return $ IP2ProxyRecord x x x x x x x x x x x (- 1 )
448- else if ipnum >= from && ipnum <= to
453+ else if ipnum >= fromV4Mapped && ipnum <= toV4Mapped
449454 then do
450- return $ search4 contents (ipnum - (toInteger from )) (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta) mode
451- else if ipnum >= fromA && ipnum <= toA
455+ return $ search4 contents (ipnum - (toInteger fromV4Mapped )) (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta) mode
456+ else if ipnum >= from6To4 && ipnum <= to6To4
452457 then do
453- return $ search4 contents ipnum (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta) mode
454- else do
455- return $ search6 contents ipnum (databasetype meta) 0 (ipv6databasecount meta) (ipv6databaseaddr meta) (ipv6indexbaseaddr meta) (ipv6columnsize meta) mode
458+ return $ search4 contents ((ipnum `rotateR` 80 ) .&. last32Bits) (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta) mode
459+ else if ipnum >= fromTeredo && ipnum <= toTeredo
460+ then do
461+ return $ search4 contents ((complement ipnum) .&. last32Bits) (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta) mode
462+ else if ipnum >= fromV4Compatible && ipnum <= toV4Compatible
463+ then do
464+ return $ search4 contents ipnum (databasetype meta) 0 (ipv4databasecount meta) (ipv4databaseaddr meta) (ipv4indexbaseaddr meta) (ipv4columnsize meta) mode
465+ else do
466+ return $ search6 contents ipnum (databasetype meta) 0 (ipv6databasecount meta) (ipv6databaseaddr meta) (ipv6indexbaseaddr meta) (ipv6columnsize meta) mode
0 commit comments