Skip to content

Commit 3e890d5

Browse files
Initial commit
1 parent 60e1a0b commit 3e890d5

File tree

4 files changed

+820
-0
lines changed

4 files changed

+820
-0
lines changed

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
IP2Location Lua Package
2+
======================
3+
4+
This Lua package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type from IP address by using IP2Location database. This package uses a file based database available at IP2Location.com. This database simply contains IP blocks as keys, and other information such as country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type as values. It supports both IP address in IPv4 and IPv6.
5+
6+
This package can be used in many types of projects such as:
7+
8+
- select the geographically closest mirror
9+
- analyze your web server logs to determine the countries of your visitors
10+
- credit card fraud detection
11+
- software export controls
12+
- display native language and currency
13+
- prevent password sharing and abuse of service
14+
- geotargeting in advertisement
15+
16+
The database will be updated in monthly basis for the greater accuracy. Free LITE databases are available at https://lite.ip2location.com/ upon registration.
17+
18+
The paid databases are available at https://www.ip2location.com under Premium subscription package.
19+
20+
21+
Installation
22+
=======
23+
24+
```
25+
luarocks install ip2location
26+
```
27+
28+
Example
29+
=======
30+
31+
```lua
32+
ip2location = require('ip2location')
33+
34+
local ip2loc = ip2location:new('IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN')
35+
36+
local result = ip2loc:get_all('8.8.8.8')
37+
38+
print("country_short: " .. result.country_short)
39+
print("country_long: " .. result.country_long)
40+
print("region: " .. result.region)
41+
print("city: " .. result.city)
42+
print("isp: " .. result.isp)
43+
print("latitude: " .. result.latitude)
44+
print("longitude: " .. result.longitude)
45+
print("domain: " .. result.domain)
46+
print("zipcode: " .. result.zipcode)
47+
print("timezone: " .. result.timezone)
48+
print("netspeed: " .. result.netspeed)
49+
print("iddcode: " .. result.iddcode)
50+
print("areacode: " .. result.areacode)
51+
print("weatherstationcode: " .. result.weatherstationcode)
52+
print("weatherstationname: " .. result.weatherstationname)
53+
print("mcc: " .. result.mcc)
54+
print("mnc: " .. result.mnc)
55+
print("mobilebrand: " .. result.mobilebrand)
56+
print("elevation: " .. result.elevation)
57+
print("usagetype: " .. result.usagetype)
58+
```
59+
60+
Dependencies
61+
============
62+
63+
The complete database is available at https://www.ip2location.com under subscription package.
64+
65+
66+
IPv4 BIN vs IPv6 BIN
67+
====================
68+
69+
Use the IPv4 BIN file if you just need to query IPv4 addresses.
70+
Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
71+
72+
73+
Copyright
74+
=========
75+
76+
Copyright (C) 2018 by IP2Location.com, support@ip2location.com

ip2location-8.0.3-1.rockspec

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package = "IP2Location"
2+
version = "8.0.3-1"
3+
source = {
4+
url = "https://github.com/ip2location/ip2location-lua"
5+
}
6+
description = {
7+
summary = "IP2Location Lua Package",
8+
detailed = [[
9+
This Lua package provides a fast lookup of country, region, city, latitude, longitude, ZIP code,
10+
time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name,
11+
mcc, mnc, mobile brand, elevation, and usage type from IP address by using IP2Location database.
12+
This package uses a file based database available at IP2Location.com. This database simply contains
13+
IP blocks as keys, and other information such as country, region, city, latitude, longitude, ZIP code,
14+
time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name,
15+
mcc, mnc, mobile brand, elevation, and usage type as values. It supports both IP address in IPv4 and IPv6.
16+
]],
17+
homepage = "https://www.ip2location.com/developers/lua",
18+
license = "MIT",
19+
maintainer = "support@ip2location.com"
20+
}
21+
dependencies = {
22+
"lua >= 5.3",
23+
"lua-nums"
24+
}
25+
build = {
26+
type = "builtin",
27+
modules = {
28+
["ip2location"] = "ip2location.lua"
29+
}
30+
}

0 commit comments

Comments
 (0)