|
@@ -6,7 +6,7 @@
|
|
|
|
|
|
import Operation from "../Operation";
|
|
import Operation from "../Operation";
|
|
import OperationError from "../errors/OperationError";
|
|
import OperationError from "../errors/OperationError";
|
|
-import {ipv4CidrRange, ipv4HyphenatedRange, ipv6CidrRange, ipv6HyphenatedRange} from "../lib/IP";
|
|
|
|
|
|
+import {ipv4CidrRange, ipv4HyphenatedRange, ipv4ListedRange, ipv6CidrRange, ipv6HyphenatedRange} from "../lib/IP";
|
|
|
|
|
|
/**
|
|
/**
|
|
* Parse IP range operation
|
|
* Parse IP range operation
|
|
@@ -21,7 +21,7 @@ class ParseIPRange extends Operation {
|
|
|
|
|
|
this.name = "Parse IP range";
|
|
this.name = "Parse IP range";
|
|
this.module = "JSBN";
|
|
this.module = "JSBN";
|
|
- this.description = "Given a CIDR range (e.g. <code>10.0.0.0/24</code>) or a hyphenated range (e.g. <code>10.0.0.0 - 10.0.1.0</code>), this operation provides network information and enumerates all IP addresses in the range.<br><br>IPv6 is supported but will not be enumerated.";
|
|
|
|
|
|
+ this.description = "Given a CIDR range (e.g. <code>10.0.0.0/24</code>), hyphenated range (e.g. <code>10.0.0.0 - 10.0.1.0</code>), or a list of IPs, (this operation provides network information and enumerates all IP addresses in the range.<br><br>IPv6 is supported but will not be enumerated";
|
|
this.infoURL = "https://wikipedia.org/wiki/Subnetwork";
|
|
this.infoURL = "https://wikipedia.org/wiki/Subnetwork";
|
|
this.inputType = "string";
|
|
this.inputType = "string";
|
|
this.outputType = "string";
|
|
this.outputType = "string";
|
|
@@ -59,6 +59,7 @@ class ParseIPRange extends Operation {
|
|
// Check what type of input we are looking at
|
|
// Check what type of input we are looking at
|
|
const ipv4CidrRegex = /^\s*((?:\d{1,3}\.){3}\d{1,3})\/(\d\d?)\s*$/,
|
|
const ipv4CidrRegex = /^\s*((?:\d{1,3}\.){3}\d{1,3})\/(\d\d?)\s*$/,
|
|
ipv4RangeRegex = /^\s*((?:\d{1,3}\.){3}\d{1,3})\s*-\s*((?:\d{1,3}\.){3}\d{1,3})\s*$/,
|
|
ipv4RangeRegex = /^\s*((?:\d{1,3}\.){3}\d{1,3})\s*-\s*((?:\d{1,3}\.){3}\d{1,3})\s*$/,
|
|
|
|
+ ipv4ListRegex = /^\s*(((?:\d{1,3}\.){3}\d{1,3})(\/(\d\d?))?(\n|$)(\n*))*$/,
|
|
ipv6CidrRegex = /^\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\/(\d\d?\d?)\s*$/i,
|
|
ipv6CidrRegex = /^\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\/(\d\d?\d?)\s*$/i,
|
|
ipv6RangeRegex = /^\s*(((?=.*::)(?!.*::[^-]+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*-\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\17)::|:\b|(?![\dA-F])))|(?!\16\17)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i;
|
|
ipv6RangeRegex = /^\s*(((?=.*::)(?!.*::[^-]+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*-\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\17)::|:\b|(?![\dA-F])))|(?!\16\17)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i;
|
|
let match;
|
|
let match;
|
|
@@ -67,6 +68,8 @@ class ParseIPRange extends Operation {
|
|
return ipv4CidrRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);
|
|
return ipv4CidrRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);
|
|
} else if ((match = ipv4RangeRegex.exec(input))) {
|
|
} else if ((match = ipv4RangeRegex.exec(input))) {
|
|
return ipv4HyphenatedRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);
|
|
return ipv4HyphenatedRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);
|
|
|
|
+ } else if ((match = ipv4ListRegex.exec(input))) {
|
|
|
|
+ return ipv4ListedRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);
|
|
} else if ((match = ipv6CidrRegex.exec(input))) {
|
|
} else if ((match = ipv6CidrRegex.exec(input))) {
|
|
return ipv6CidrRange(match, includeNetworkInfo);
|
|
return ipv6CidrRange(match, includeNetworkInfo);
|
|
} else if ((match = ipv6RangeRegex.exec(input))) {
|
|
} else if ((match = ipv6RangeRegex.exec(input))) {
|