Coder Social home page Coder Social logo

ipdb-luajit's People

Contributors

ilsanbao avatar ipipdotnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipdb-luajit's Issues

怎么解决lua entry thread aborted: memory allocation error: not enough memory

怎么解决类似下面的问题呢?都是按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'

ip解析不正确

您好,我使用您们提供的ipdb-luajit解析ipv4地址001.000.128.000得到结果为:

image
然后,在使用相同的ipdb文件的情况下,使用ipdb-go解析001.000.128.000的结果为:
image

经过对比发现ipdb-luajit reader.lua里调用的C函数inet_pton:
image
无法正确处理001.000.128.000这种有前导0的ip,以下是inet_pton分别对001.000.128.000和1.0.128.0的处理结果:
1)001.000.128.000 不正常
image
2)1.0.128.0 正常
image

This implementation is different from the other ipdb-*

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.