sinamics/ztnet

Cannot add IPv6 address to a client due to IPv4 only regex

Closed this issue · 2 comments

The following line only allows IPv4 addresses to be added:

This regex should be correct, but feel free to test.

const regex = new RegExp(
    "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
    "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
    "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
    "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|" +
    "(([0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7})|" +
    "([0-9a-fA-F]{1,4}:){1,7}:|" +
    "([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|" +
    "::([0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}|" +
    "([0-9a-fA-F]{1,4}:){1,4}:([0-9a-fA-F]{1,4}:){1,3}[0-9a-fA-F]{1,4})$"
);

I will do some testing. Thank you.

Also line 150 only outputs the route, not the input IP which caused my initial confusion.