Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pine/self-ip
:loop: Get self IP addresses
https://github.com/pine/self-ip
ip ipv4 ipv6 javascript nodejs
Last synced: 26 days ago
JSON representation
:loop: Get self IP addresses
- Host: GitHub
- URL: https://github.com/pine/self-ip
- Owner: pine
- License: mit
- Created: 2016-07-12T14:15:10.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2023-01-04T07:42:29.000Z (almost 2 years ago)
- Last Synced: 2024-04-15T15:34:33.855Z (7 months ago)
- Topics: ip, ipv4, ipv6, javascript, nodejs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/self-ip
- Size: 52.7 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# self-ip [![npm](https://img.shields.io/npm/v/self-ip.svg?maxAge=2592000&style=shield)](https://www.npmjs.org/package/self-ip) [![build](https://github.com/pine/self-ip/actions/workflows/build.yml/badge.svg)](https://github.com/pine/self-ip/actions/workflows/build.yml) [![License](https://img.shields.io/github/license/emoji-gen/clone-into.svg)](LICENSE)
Get self IP addresses
## Features
- Supports TypeScript
- Supports both CommonJS and ESModules## Getting Started
```sh
$ npm install --save self-ip # for npm users
$ yarn add self-ip # for yarn users
```## Breaking Changes
There are breaking changes in `v1.0.0`. See [the release note](https://github.com/pine/self-ip/releases/tag/v1.0.0) for more details.## Usage
### ESModules```js
import { ip, ipv4, ipv6 } from 'self-ip'ip()
// ==> { v4: ['192.0.0.2'], v6: ['ffff::abcd:1234:1234:5678'] }ipv4()
// ==> ['192.0.0.2']ipv6()
// ==> ['ffff::abcd:1234:1234:5678']
```### CommonJS
```js
const { ip, ipv4, ipv6 } = require('self-ip')ip()
// ==> { v4: ['192.0.0.2'], v6: ['ffff::abcd:1234:1234:5678'] }ipv4()
// ==> ['192.0.0.2']ipv6()
// ==> ['ffff::abcd:1234:1234:5678']
```## Reference
### `ip([ checker ])`
Get both IPv4 and IPv6 self-addresses- `checker(addrs, name)` (function): check if it is a loopback network interface or not
- default: [is-lo](https://github.com/pine/is-lo) module
- **Result** (Object): `{ v4: ['v4addr'], v6: ['v6addr'] }`### `ipv4([ checker ])`
Get IPv4 self-addresses- `checker(addrs, name)` (function): check if it is a loopback network interface or not
- default: [is-lo](https://github.com/pine/is-lo) module
- **Result** (Array): `['v4addr']`### `ipv6([ checker ])`
Get IPv6 self-addresses- `checker(addrs, name)` (function): check if it is a loopback network interface or not
- default: [is-lo](https://github.com/pine/is-lo) module
- **Result** (Array): `['v6addr']`## License
MIT © [Pine Mizune](https://profile.pine.moe)