Skip to content

Commit fa4167c

Browse files
Added support for 6to4 and Teredo.
1 parent 96a4693 commit fa4167c

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

LICENSE.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 IP2Location.com
3+
Copyright (c) 2019 IP2Location.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
4949
Copyright
5050
=========
5151

52-
Copyright (C) 2018 by IP2Location.com, support@ip2location.com
52+
Copyright (C) 2019 by IP2Location.com, support@ip2location.com

ip2location.erl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}).
2525

2626
apiversion() ->
27-
"8.0.3".
27+
"8.1.0".
2828

2929
getapiversion() ->
3030
io:format("API Version: ~p~n", [apiversion()]).
@@ -293,8 +293,13 @@ search6(S, Ipnum, Dbtype, Low, High, Baseaddr, Indexbaseaddr, Colsize) ->
293293
end.
294294

295295
query(Ip) ->
296-
From = 281470681743360,
297-
To = 281474976710655,
296+
Fromv4mapped = 281470681743360,
297+
Tov4mapped = 281474976710655,
298+
From6to4 = 42545680458834377588178886921629466624,
299+
To6to4 = 42550872755692912415807417417958686719,
300+
Fromteredo = 42540488161975842760550356425300246528,
301+
Toteredo = 42540488241204005274814694018844196863,
302+
Last32bits = 4294967295,
298303

299304
case ets:info(mymeta) of
300305
undefined ->
@@ -329,8 +334,12 @@ query(Ip) ->
329334
{ok, {X1, X2, X3, X4, X5, X6, X7, X8}} ->
330335
Ipnum = (X1 bsl 112) + (X2 bsl 96) + (X3 bsl 80) + (X4 bsl 64) + (X5 bsl 48) + (X6 bsl 32) + (X7 bsl 16) + X8,
331336
if
332-
Ipnum >= From andalso Ipnum =< To ->
333-
search4(S, Ipnum - From, Databasetype, 0, Ipv4databasecount, Ipv4databaseaddr, Ipv4indexbaseaddr, Ipv4columnsize);
337+
Ipnum >= Fromv4mapped andalso Ipnum =< Tov4mapped ->
338+
search4(S, Ipnum - Fromv4mapped, Databasetype, 0, Ipv4databasecount, Ipv4databaseaddr, Ipv4indexbaseaddr, Ipv4columnsize);
339+
Ipnum >= From6to4 andalso Ipnum =< To6to4 ->
340+
search4(S, (Ipnum bsr 80) band Last32bits, Databasetype, 0, Ipv4databasecount, Ipv4databaseaddr, Ipv4indexbaseaddr, Ipv4columnsize);
341+
Ipnum >= Fromteredo andalso Ipnum =< Toteredo ->
342+
search4(S, ((bnot Ipnum) band Last32bits), Databasetype, 0, Ipv4databasecount, Ipv4databaseaddr, Ipv4indexbaseaddr, Ipv4columnsize);
334343
true ->
335344
search6(S, Ipnum, Databasetype, 0, Ipv6databasecount, Ipv6databaseaddr, Ipv6indexbaseaddr, Ipv6columnsize)
336345
end;

0 commit comments

Comments
 (0)