Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/znerol/ipaddrhash-js
A predictable addressing scheme for statically assigned IPv6 and IPv4 addresses based on hostnames.
https://github.com/znerol/ipaddrhash-js
Last synced: 25 days ago
JSON representation
A predictable addressing scheme for statically assigned IPv6 and IPv4 addresses based on hostnames.
- Host: GitHub
- URL: https://github.com/znerol/ipaddrhash-js
- Owner: znerol
- License: gpl-3.0
- Created: 2021-09-15T12:13:46.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-26T21:00:20.000Z (over 2 years ago)
- Last Synced: 2024-08-10T00:11:24.043Z (3 months ago)
- Language: JavaScript
- Size: 387 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
ipaddrhash
==========Implements a predictable addressing scheme for statically assigned IPv6 and
IPv4 addresses based on hostnames. Supports node and modern browsers.The algorithm used to derive an ip is simple:
ip = prefix + (sha256(seed) & hostmask)
Installation
------------```
npm install ipaddrhash --save-dev
```Usage
-----ESM:
```javascript
import { ipaddrHash, ipaddrPrefixSize } from "ipaddrhash";
```CommonJS:
```javascript
const { ipaddrHash, ipaddrPrefixSize } = require("ipaddrhash");
```Example:
```javascript
const prefix = "2001:db8::/64";
const fqdn = "example.com";
const size = ipaddrPrefixSize(prefix);
if (size !== undefined && fqdn.length > 0) {
ipaddrHash(size, prefix, fqdn).then((result) => {
// should output:
// 2001:db8::13d2:1255:86ce:1947
console.log(result);
});
}
```License
-------GNU General Public License v3.0 or later