Muthu Kumar
7 years ago
13 changed files with 1684 additions and 62 deletions
@ -0,0 +1,12 @@ |
|||
var readServers = require('../utils/listFile').readServers; |
|||
var prettyjson = require('prettyjson'); |
|||
|
|||
var EOL = require('os').EOL; |
|||
|
|||
function listServers() { |
|||
var serversList = readServers(); |
|||
if(serversList) console.log(EOL + prettyjson.render(serversList) + EOL); |
|||
else console.log("\nNo servers were found! Create some using `up`!\n"); |
|||
} |
|||
|
|||
module.exports = listServers; |
File diff suppressed because it is too large
@ -0,0 +1,7 @@ |
|||
var https = require('https'); |
|||
var fs = require('fs-extra'); |
|||
|
|||
var file = fs.createWriteStream("./assets/tlds.txt"); |
|||
https.get("https://data.iana.org/TLD/tlds-alpha-by-domain.txt", function(response) { |
|||
response.pipe(file); |
|||
}); |
@ -0,0 +1 @@ |
|||
[] |
@ -0,0 +1,61 @@ |
|||
// Module courtesy of TRGWII
|
|||
// Original: https://github.com/trgwii/isFQDN
|
|||
|
|||
'use strict'; |
|||
|
|||
var fs = require('fs-extra'); |
|||
|
|||
// Official list of TLDs should be fetched from:
|
|||
// https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
|||
|
|||
// You must have received a copy of the list along with `up`
|
|||
// Run `npm run build` to update the cached list
|
|||
|
|||
function isFQDN(domain) { |
|||
|
|||
// Importing and parsing `tlds.txt` file
|
|||
var tlds = fs.readFileSync('./assets/tlds.txt', 'utf8') |
|||
.split(/[\r\n]+/) |
|||
.filter(x => !x.startsWith('#')); |
|||
|
|||
if (domain.length > 253) { |
|||
return false; |
|||
} |
|||
|
|||
var labels = domain.split('.').reverse(); |
|||
|
|||
if (labels.length < 2) { |
|||
return false; |
|||
} |
|||
|
|||
var tld = labels[0]; |
|||
|
|||
if (!tlds.includes(tld.toUpperCase())) { |
|||
return false; |
|||
} |
|||
|
|||
for (var label of labels) { |
|||
|
|||
const len = label.length; |
|||
|
|||
if (len > 63 || len === 0) { |
|||
return false; |
|||
} |
|||
|
|||
for (let i = 0; i < len; i++) { |
|||
|
|||
const char = label[i]; |
|||
|
|||
if ((i === 0 || i === len - 1) && char === '-') { |
|||
return false; |
|||
} |
|||
|
|||
if (!char.match(/^[a-zA-Z0-9-]$/)) { |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
return true; |
|||
}; |
|||
|
|||
module.exports = isFQDN; |
@ -0,0 +1,15 @@ |
|||
function removeFromArray (arr, dom, port) { |
|||
var shouldDelete = []; |
|||
|
|||
for(var i = 0; i < arr.length; i++) if((arr[i].domain == dom) && (arr[i].outPort == port)) shouldDelete = [true, i]; |
|||
|
|||
if (shouldDelete[0]) { |
|||
arr.splice(shouldDelete[1], 1); |
|||
console.log('\nItem was deleted!\n'); |
|||
} else { |
|||
console.log('\nItem was not found!\n'); |
|||
} |
|||
return arr; |
|||
} |
|||
|
|||
module.exports = removeFromArray; |
Loading…
Reference in new issue