random-ipv4
Return a random ipv4 address.
Last updated 10 years ago by bubkoo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install random-ipv4 
SYNC missed versions from official npm registry.

random-ipv4

Return a random ipv4 address.

MIT License

build:? coverage:?

Install

$ npm install --save random-ipv4 

Usage

For more use-cases see the tests

var randomIpv4 = require('random-ipv4');

// API
// - randomIpv4(schema[, options]);

randomIpv4();
// => 193.31.235.41

randomIpv4('127.0.{token}.1', {
    token: {
        min: 127,
        max: 255
    }
});
// => 127.0.216.1

randomIpv4('{token1}.{token2}.{token3}.{token4}', {
    token1:{
        min: 127,
        max: 127
    },
    token2:{
        min: 127,
        max: 192
    },
    token3:{
        min: 0,
        max: 200
    }
});
// => 127.188.153.3

Note:

  • schema - the ipv4 schema, default '{token1}.{token2}.{token3}.{token4}'.
  • options - options for every token, each token has min and max option, which both are from 0 to 255.

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

Current Tags

  • 1.0.2                                ...           latest (10 years ago)

4 Versions

  • 1.0.2                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 4
Dependencies (2)
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |