Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么不可以fork再PR呢?,也让我可以知道我能改进的地方。 #1

Closed
lilien1010 opened this issue Jan 12, 2018 · 1 comment

Comments

@lilien1010
Copy link

readme 写的很好,
但是大部分代码都是一致的,PR的话,让我也知道可以改进优化的地方,可以让更多的人看到。
另外 readme 里面有些地方地址是错的。

@anjia0532
Copy link
Owner

anjia0532 commented Jan 14, 2018

你好,readme和主代码,确实是以你的为基础版本。但是实际上是不管是readme还是lib/resty/maxminddb.lua 部分都变更了很多。

因为 https://github.com/lilien1010/lua-resty-maxminddb 只可以获取area_code,不满足需求,所以决定自己改造。

比如 readme 仅 Bug Reports部分未变更,issues地址还是你的库的,哈哈(现已更正)
而 maxminddb.lua 中,仅struct全部和_M:lookup(ip)部分未变更,其余部分基本都变了。主要体现在,去除原有,仅能查询区域编码的函数,根据 libmaxminddb/maxminddb.c#L1938 库C编码,翻译成lua代码,实现了返回全部内容的函数local function _dump_entry_data_list(entry_data_list,status,resultTab) 这是我这版的精华所在。
用户可以根据 local res,err = maxm:lookup(ngx.var.arg_ip or ngx.var.remote_addr) 取到的res是一个json,可以res['city'] res['country'] ... 自主选择返回内容。更加灵活。

在由C移植到lua中遇到很多问题,在openresty 的邮件列表中也请教过别人,包括但不限于 [求教]关于lua.ffi调用C

下图为用beyond compare 比对的结果,红色部分是差异部分。对比发现,差异还是挺大的

snipaste20180114_101026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants