mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-09 15:55:01 -04:00
Improved ParseIPv6Address formatting
This commit is contained in:
parent
7af7b4df5e
commit
444065c926
2 changed files with 220 additions and 222 deletions
|
@ -403,7 +403,7 @@ export function strToIpv6(ipStr, retArr=true) {
|
|||
return ipStr;
|
||||
}
|
||||
let expandedStr = ipStr.substring(0, compactIndex); // 1234:5678::..
|
||||
const insertOffset = compactIndex == 0 ? 1 : 0;
|
||||
const insertOffset = compactIndex == 0;
|
||||
const ipEnd = ipStr.substring(compactIndex + 1);
|
||||
const missingChars = 39 - (expandedStr.length + ipEnd.length);
|
||||
for (let i = insertOffset; i < missingChars + insertOffset; i++) {
|
||||
|
|
|
@ -38,8 +38,9 @@ class ParseIPv6Address extends Operation {
|
|||
run(input, args) {
|
||||
let match,
|
||||
output = "";
|
||||
|
||||
if ((match = IPV6_REGEX.exec(input))) {
|
||||
if (!(match = IPV6_REGEX.exec(input))) {
|
||||
throw new OperationError("Invalid IPv6 address.");
|
||||
}
|
||||
const ipv6 = strToIpv6(match[1]),
|
||||
longhand = ipv6ToStr(ipv6),
|
||||
shorthand = ipv6ToStr(ipv6, true);
|
||||
|
@ -265,9 +266,6 @@ class ParseIPv6Address extends Operation {
|
|||
output += "\nInterface identifier: " + intIdent +
|
||||
"\nMAC address: " + mac;
|
||||
}
|
||||
} else {
|
||||
throw new OperationError("Invalid IPv6 address");
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue