Skip to content

Support for "edge-case" ip notations #142

@StoneLabs

Description

@StoneLabs

Currently, there seem to be quite a lot of valid IPs that throw [AddressError]: Invalid IPv4 address.

var Address4 = require('ip-address').Address4;

// All of the following are rejected as invalid.
const topic = new Address4('127.1'); // equivalent to 127.0.0.1
const topic = new Address4('127.0.1'); // equivalent to 127.0.0.1
const topic = new Address4('192.168.36095'); // equivalent to 192.168.140.255 in CLASS B notation
const topic = new Address4('192.11046143');  // equivalent to 192.168.140.255 in CLASS C notation
const topic = new Address4('0xc0.0xa8.0x8c.0xff');  // equivalent to 192.168.140.255 in valid hex notation
const topic = new Address4('0300.0250.0214.0377');  // equivalent to 192.168.140.255 in valid oct notation (though some implementations ignore oct notation)
const topic = new Address4('0000000001.0000000002.0000000003.000000010');  // equivalent to 1.2.3.8 in valid oct notation (though some implementations ignore oct notation)

// Granted, these are all very absurd notations. However, all of these are valid ip's. you can verify this just pinging them.

image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions