Seiteneigenschaften |
---|
Deutsch |
---|
Beschreibung:
Dies ist eine Hilfsfunktion zur Konvertierung einer als IPv4-Adresse geschriebenen Subnetzmaske in ihr entsprechendes Suffix.
Liste der verwendeten Variablen:
Variable | Beschreibung |
---|
Add-in Code:
/**
* @param {Config} config
* @param {Context} context
* Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {
function subnetSuffix(mask) {
if (mask) {
return mask
.split(".") // ["255", "255", "255", "0"]
.map(i => (i >>> 0).toString(2)) // ["11111111", "11111111", "11111111", "0"]
.join("") // "1111111111111111111111110"
.replace(/0/g, "") // "111111111111111111111111"
.length // 24
}
return0;
}subnetSuffix("255.255.255.0"); // 24
};
Add-in als JSON-Datei:
View file |
---|
name | subnet_conversion.json |
---|
page | Umwandlung von Subnetzmasken |
---|
space | LMCADEN |
---|
height | 150 |
---|
|
...
Description:
This is a helper function to convert a subnet mask written as an IPv4 address to its equivalent suffix.
List of used variables:
Add-in code:
/** * @param {Config} config * @param {Context} context * Do not edit this comment or parameter types. Required for code suggestions */ exports.main = function (config, context) { function subnetSuffix(mask) { if (mask) { return mask .split( "." ) // ["255", "255", "255", "0"] .map(i => (i >>> 0 ).toString( 2 )) // ["11111111", "11111111", "11111111", "0"] .join( "" ) // "1111111111111111111111110" .replace( /0/ g , "" ) // "111111111111111111111111" .length // 24 } return 0 ; }
subnetSuffix(
"255.255.255.0"
);
// 24
};
|
---|
Add-in as JSON file:
View file |
---|
name | subnet_conversion.json |
---|
|
...