Skip to content

Subnet info is lost when converting to v4 address. #123

@momchil-anachkov

Description

@momchil-anachkov

Hi there,

It seems when converting to a v4 from a v6 address the the resulting v4 address does not retain any of the subnet information even when coming from a "v4 in v6" address.

Steps to reproduce:

const a = Address6.fromAddress4('192.168.0.1/24'); // 24 bit mask
console.log(a.address); // ::ffff:192.168.0.1/120
console.log(a.subnet); // '/120'
console.log(a.subnetMask); // 120
console.log(a.is4()); // true
console.log(a.v4); // true

// This is where the funkiness starts

console.log(a.parsedAddress4); // '192.168.0.1' -- no mask
console.log(a.address4.address); // '192.168.0.1' -- no mask
console.log(a.to4().subnet); // '/32'
console.log(a.to4().subnetMask); // 32

I was expecting if the address is a valid v4 address for it to be preserved with the subnet (24), and not get the default (32).
Am I missing something?

Cheers

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