All Projects → chill117 → geoip-native-lite

chill117 / geoip-native-lite

Licence: MIT license
Super-fast IP to country lookups for node.js with minimal RAM usage.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to geoip-native-lite

jqIpLocation
jqIpLocation – jQuery Plugin that returns the location of an IP address in JSON format
Stars: ✭ 18 (+20%)
Mutual labels:  country, ip
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (+360%)
Mutual labels:  country, ip
MicroDNSSrv
A micro DNS server for MicroPython to simply respond to A queries on multi-domains with or without wildcards (used on Pycom modules & ESP32)
Stars: ✭ 43 (+186.67%)
Mutual labels:  lookup, ip
Country Ip Blocks
CIDR country-level IP data, straight from the Regional Internet Registries, updated hourly.
Stars: ✭ 100 (+566.67%)
Mutual labels:  country, ip
postcss-property-lookup
PostCSS plugin for property lookups, similar to Stylus
Stars: ✭ 67 (+346.67%)
Mutual labels:  lookup
csc picker
A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.
Stars: ✭ 25 (+66.67%)
Mutual labels:  country
uzakel
Verimerkezleri Arası IP Engelleme Sistemi
Stars: ✭ 17 (+13.33%)
Mutual labels:  ip
node-ip2region
IP/IPv6 to region on Node.js (IP/IPv6 地址到区域运营商)
Stars: ✭ 95 (+533.33%)
Mutual labels:  ip
IP-Monitor
CSDN博客
Stars: ✭ 32 (+113.33%)
Mutual labels:  ip
web-coronavirus-stats
🌎 🦠 😷 Coronavirus disease (COVID-2019) global / world / country statistics and reports
Stars: ✭ 2 (-86.67%)
Mutual labels:  country
ipwatch
This program gets your external, & internal, IP addresses, checks them against your "saved" IP addresses and, if a difference is found, emails you the new IP(s). This is useful for servers at residential locations whose IP address may change periodically due to actions by the ISP.
Stars: ✭ 38 (+153.33%)
Mutual labels:  ip
hscode
📘🖥 A command line reference tool for http status codes.
Stars: ✭ 31 (+106.67%)
Mutual labels:  lookup
client-ip
PSR-15 middleware to detect the client ip and save it as a request attribute.
Stars: ✭ 15 (+0%)
Mutual labels:  ip
ip
Validate if an ip address is public or private.
Stars: ✭ 15 (+0%)
Mutual labels:  ip
Country
Country gives a list of countries with all their flags.
Stars: ✭ 26 (+73.33%)
Mutual labels:  country
pikaz-location
定位插件(限中国)
Stars: ✭ 78 (+420%)
Mutual labels:  ip
echoIP
显示客户端IP的详细信息
Stars: ✭ 63 (+320%)
Mutual labels:  ip
PhoneCountryCodePicker
An iOS tableview picker for PhoneCountryCode (English & Chinese supported)
Stars: ✭ 31 (+106.67%)
Mutual labels:  country
captcp
A open source program for TCP analysis of PCAP files
Stars: ✭ 110 (+633.33%)
Mutual labels:  ip
Nager.Country
Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
Stars: ✭ 68 (+353.33%)
Mutual labels:  country

geoip-native-lite

!! NOT MAINTAINED !!

This project is no longer maintained. Please use geoip-lite instead.

!! NOT MAINTAINED !!

Goals

  • Fast IP address to country lookup:
    • 1,000,000+ ops/second for IPv4 addresses
    • 500,000+ ops/second for IPv6 addresses
  • Minimal RAM usage
  • Native JavaScript implementation for ease-of-use and portability

Installation

Add to your application via npm:

npm install geoip-native-lite --save

This will install geoip-native-lite and add it to your application's package.json file.

Update Data Files

This module ships with pre-built data files. If you'd like to update the data files for yourself, run the update script like this:

npm run updatedata

How to Use

lookup

lookup(ip)

Lookup the country in which the IP address is located. Supports both ipv4 and ipv6.

Usage:

var GeoIpNativeLite = require('geoip-native-lite');

// Must load data before lookups can be performed.
GeoIpNativeLite.loadDataSync();

// Data loaded successfully.
// Ready for lookups.
var ip = '128.21.16.34';
var country = GeoIpNativeLite.lookup(ip);

if (country) {
	console.log(ip, 'is geo-located in', country.toUpperCase());
} else {
	console.log('Failed to geo-locate the IP address:', ip);
}

loadData

loadData([options, ]cb)

Asynchronously loads geoip data.

Usage:

var GeoIpNativeLite = require('geoip-native-lite');

GeoIpNativeLite.loadData(options, function(error, data) {

	if (error) {
		// Something went wrong.
	} else {
		// Data loaded successfully.
		// Ready for lookups.
	}
});

Options:

var options = {

	/*
		Set to TRUE to load ipv4 geoip data.

		Default value is TRUE.
	*/
	ipv4: true,

	/*
		Set to TRUE to load ipv6 geoip data.

		Default value is FALSE.
	*/
	ipv6: false,

	/*
		Set to TRUE to cache data in memory.

		Default value is TRUE.
	*/
	cache: true
};

loadDataSync

loadDataSync([options])

Synchronously loads geoip data.

Usage:

var GeoIpNativeLite = require('geoip-native-lite');

GeoIpNativeLite.loadDataSync(options);

var country = GeoIpNativeLite.lookup('198.169.246.30');

Options:

var options = {

	/*
		Set to TRUE to load ipv4 geoip data.

		Default value is TRUE.
	*/
	ipv4: true,

	/*
		Set to TRUE to load ipv6 geoip data.

		Default value is FALSE.
	*/
	ipv6: false,

	/*
		Set to TRUE to cache data in memory.

		Default value is TRUE.
	*/
	cache: true
};

Contributing

There are a number of ways you can contribute:

  • Improve or correct the documentation - All the documentation is in this readme.md file. If you see a mistake, or think something should be clarified or expanded upon, please submit a pull request
  • Report a bug - Please review existing issues before submitting a new one; to avoid duplicates. If you can't find an issue that relates to the bug you've found, please create a new one.
  • Request a feature - Again, please review the existing issues before posting a feature request. If you can't find an existing one that covers your feature idea, please create a new one.
  • Fix a bug - Have a look at the existing issues for the project. If there's a bug in there that you'd like to tackle, please feel free to do so. I would ask that when fixing a bug, that you first create a failing test that proves the bug. Then to fix the bug, make the test pass. This should hopefully ensure that the bug never creeps into the project again. After you've done all that, you can submit a pull request with your changes.

Tests

To run all tests (except benchmarks):

npm test

To run benchmarks:

npm run test:benchmarks

To run only unit tests:

npm run test:unit

To run only code-style checks:

npm run lint

Licensing

All the code in this project is MIT licensed.

The geoip data used in this project is licensed separately.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].