@@ -261,11 +261,11 @@ function ip2location:new(dbpath)
261261 x .productcode = readuint8 (30 , x .f )
262262 x .producttype = readuint8 (31 , x .f )
263263 x .filesize = readuint32 (32 , x .f ):asnumber ()
264-
265- -- check if is correct BIN (should be 1 for IP2Location BIN file), also checking for zipped file (PK being the first 2 chars)
266- if (x .productcode ~= 1 and x .databaseyear >= 21 ) or (x .databasetype == 80 and x .databasecolumn == 75 ) then -- only BINs from Jan 2021 onwards have this byte set
267- error (invalid_bin )
268- end
264+
265+ -- check if is correct BIN (should be 1 for IP2Location BIN file), also checking for zipped file (PK being the first 2 chars)
266+ if (x .productcode ~= 1 and x .databaseyear >= 21 ) or (x .databasetype == 80 and x .databasecolumn == 75 ) then -- only BINs from Jan 2021 onwards have this byte set
267+ error (invalid_bin )
268+ end
269269
270270 x .ipv4columnsize = x .databasecolumn * 4 -- 4 bytes each column
271271 x .ipv6columnsize = 16 + ((x .databasecolumn - 1 ) * 4 ) -- 4 bytes each column, except IPFrom column which is 16 bytes
@@ -438,9 +438,9 @@ function ip2location:checkip(ip)
438438 -- DEBUGGING CODE
439439 -- for key, value in pairs(chunks)
440440 -- do
441- -- print(key, " -- " , value);
441+ -- print(key, " -- " , value);
442442 -- end
443-
443+
444444 -- only support full IPv6 format for now
445445 if # chunks == 8 then
446446 local ipnum = bn .ZERO
@@ -450,9 +450,9 @@ function ip2location:checkip(ip)
450450 if # v > 0 and part > 65535 then return R .ERROR end
451451 ipnum = ipnum + (bn (part ) << (16 * (8 - x )))
452452 end
453-
453+
454454 local override = 0
455-
455+
456456 -- special cases which should convert to equivalent IPv4
457457 if ipnum >= from_v4mapped and ipnum <= to_v4mapped then -- ipv4-mapped ipv6
458458 override = 1
@@ -468,7 +468,7 @@ function ip2location:checkip(ip)
468468 ipnum2 = ipnum :asnumber () & 0xffffffff
469469 ipnum = bn (ipnum2 ) -- convert back to bn
470470 end
471-
471+
472472 local ipindex = 0 ;
473473 if override == 1 then
474474 if self .ipv4indexbaseaddr > 0 then
@@ -682,7 +682,7 @@ function ip2location:query(ipaddress, mode)
682682 if (mode &modes .usagetype ~= 0 ) and (self .usagetype_enabled == true ) then
683683 result .usagetype = readstr (readuint32row (self .usagetype_position_offset , row ):asnumber (), self .f )
684684 end
685-
685+
686686 if (mode &modes .addresstype ~= 0 ) and (self .addresstype_enabled == true ) then
687687 result .addresstype = readstr (readuint32row (self .addresstype_position_offset , row ):asnumber (), self .f )
688688 end
0 commit comments