Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ipnation
Advanced tools
Readme
Quickly convert an IPv4 address to an ISO Nation
npm install ipnation
> var ipnation = require('ipnation');
> ipnation.fromIPv4('50.19.117.93').then(function(res) {
console.log(res);
});
{
iso2: 'US',
iso3: 'USA',
isoNation: 'United States'
}
fromIPv4(address)
Query the IPv4 address space for a matching ISO nation code.
Arguments
address
: String; a dot-decimal IPv4 address (e.g. 50.19.117.93
)Returns
Promise that resolves to an ISO code set for the address; the promise is rejected with an error if the address is malformed or invalid
Example
> ipnation.fromIPv4('50.19.117.93').then(function(res) {
console.log(res);
});
{
iso2: 'US',
iso3: 'USA',
isoNation: 'United States'
}
This project is based on the publicly available dataset at ip2nation.com. The source data has been migrated to the following schema:
ipv4_iso3
field | type definition | |
---|---|---|
* | ip | UNSIGNED INTEGER |
iso3 | CHAR(3) |
ip
is the dot-decimal IPv4 address converted to binary representation (inet_aton
) then unpacked to a long integer.
iso_nations
field | type definition | |
---|---|---|
iso2 | CHAR(2) | |
* | iso3 | CHAR(3) |
iso_nation | VARCHAR(255) |
All data resides in a local SQLite3 database which provides portable storage, efficient indexing, and fast querying. If you receive build warnings/errors from SQLite, consult the node-sqlite3
documentation.
Nation data is based on ISO 3166-1 country codes available in the source dataset with a few additions necessary to achieve internal consistency:
AP
; APN
; Asia/Pacific RegionBQ
; BES
; Bonaire, Sint Eustatius and SabaCW
; CUW
; CuracaoEU
, EUR
, EuropeGG
; GGY
; GuernseyIM
; IMN
; Isle of ManJE
, JEY
, JerseyMF
, MAF
, Saint Martin (French)SS
, SSD
, South SudanSX
, SXM
, Sint Maarten (Dutch)Currently, a few addresses may resolve to an unknown nation response:
{
iso2: '??',
iso3: '???',
isoNation: 'UNK'
}
npm test
To get the coverage report:
npm run coverage
Detailed reports are available in the ./artifacts
directory. This project maintains 100% coverage of functions and 80%+ coverage of branches.
PRs are welcome! PRs must improve or maintian test coverage to be accepted.
For bugs, please include a failing test which passes when your PR is applied. For CRUD actions against the underlying SQLite database, please submit a .sql
migration file in the sql
directory.
FAQs
Quickly convert an IP address to ISO nation data
The npm package ipnation receives a total of 1 weekly downloads. As such, ipnation popularity was classified as not popular.
We found that ipnation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.