mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-04 00:40:27 +00:00
Add maxmind to redbean
This commit is contained in:
parent
af645fcbec
commit
c371db6663
11 changed files with 2457 additions and 2 deletions
|
@ -1146,6 +1146,26 @@ RE MODULE
|
|||
end of the line. This flag may only be used with re.search and
|
||||
regex_t*:search.
|
||||
|
||||
MAXMIND MODULE
|
||||
|
||||
This module may be used to get city/country/asn/etc from IPs, e.g.
|
||||
|
||||
-- .init.lua
|
||||
maxmind = require "maxmind"
|
||||
asndb = maxmind.open('/usr/local/share/maxmind/GeoLite2-ASN.mmdb')
|
||||
|
||||
-- request handler
|
||||
as = asndb:lookup(GetRemoteAddr())
|
||||
if as then
|
||||
asnum = as:get("autonomous_system_number")
|
||||
asorg = as:get("autonomous_system_organization")
|
||||
Write(EscapeHtml(asnum))
|
||||
Write(' ')
|
||||
Write(EscapeHtml(asorg))
|
||||
end
|
||||
|
||||
For further details, please see tool/net/lmaxmind.c
|
||||
|
||||
CONSTANTS
|
||||
|
||||
kLogDebug
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue