ipipdotnet / ipdb-luajit Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
ipipfree.ipdb
local ipiploc = ipdb:find(ipipargs["ip"], "CN");
怎么解决类似下面的问题呢?都是按git里的方法使用的
2020/01/15 10:10:36 [error] 31256#0: *111517685 lua entry thread aborted: memory allocation error: not enough memory
stack traceback:
coroutine 0:
[C]: in function 'read'
/home/work/local/openresty/lualib/resty/ipdb/reader.lua:97: in function 'new'
/home/work/local/openresty/lualib/resty/ipdb/city.lua:14: in function 'new'
After reading several ipdb-* implementations, like:
Java: https://github.com/ipipdotnet/ipdb-java
Python: https://github.com/ipipdotnet/ipdb-python
C: https://github.com/ipipdotnet/ipdb-c
LuaJIT: https://github.com/ipipdotnet/ipdb-luajit (This one)
I realize that this implementation is different from the others in some details.
For example,
https://github.com/ipipdotnet/ipdb-luajit/blob/master/resty/ipdb/reader.lua#L148
for i = 0, 95 do
if i >= 80 then
Unlike other implementations, this one doesn't check if current node
is larger than the nodeCount
.
https://github.com/ipipdotnet/ipdb-luajit/blob/master/resty/ipdb/reader.lua#L161
for i = 0, 128 do
local val = band(1, rshift(ip_address[rshift(i, 3)], 7 - (i % 8)))
Other implementations use bitCount
(which is 32 for IPv4, 128 for IPv6) as the upper boundary. But this one use a hard-code 128. BTW, it should be i = 0, 127
.
https://github.com/ipipdotnet/ipdb-luajit/blob/master/resty/ipdb/reader.lua#L163
node = read_node(self.data, node, val)
if node > self.node_count then
break
end
While other implementations check node > nodeCount
before read_node
, this implementation checks it after read_node
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.