Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isHostnameIpAddress(hostname) {
hostname = getHostnameFromMatrixDomain(hostname);
if (!hostname) return false;
// is-ip doesn't want IPv6 addresses surrounded by brackets, so
// take them off.
if (hostname.startsWith("[") && hostname.endsWith("]")) {
hostname = hostname.substring(1, hostname.length - 1);
}
return isIp(hostname);
}
function pingSecureNode() {
if (isValidDomainName(settings.secureNodeFQDN)) {
let ping = require('ping');
const isIp = require('is-ip');
let fqdnIsV6 = isIp.v6(settings.secureNodeFQDN);
let cfg = {
v6: fqdnIsV6,
};
let hosts = [settings.secureNodeFQDN];
hosts.forEach(function (host) {
ping.sys.probe(host, function (isAlive) {
toggleLedHTML();
if (ledWrapperExists()){
if (isAlive) {
document.getElementById("dotSNstatus").style.backgroundColor = "#34A853"; // green #34A853
} else {
document.getElementById("dotSNstatus").style.backgroundColor = "#EA4335"; // red #EA4335
document.getElementById("dotSNstatusRPC").style.backgroundColor = "#EA4335"; // red #EA4335
}
const selfsigned = (name, dir) => {
if (fs.existsSync(path.join(dir, 'key.pem'))) {
const keyPem = fs.readFileSync(path.join(dir, 'key.pem'))
, certPem = fs.readFileSync(path.join(dir, 'cert.pem'))
, cert = forge.pki.certificateFromPem(certPem)
, certDer = forge.asn1.toDer(forge.pki.certificateToAsn1(cert)).getBytes()
, fprint = forge.md.sha1.create().update(certDer).digest().toHex().match(/../g).join(':')
console.log(`Loaded TLS certificate with fingerprint ${fprint} from ${ dir }`)
return { key: keyPem, cert: certPem }
}
const extensions = [ ...defaultExt, {
name: 'subjectAltName'
, altNames: [ isIp(name) ? { type: 7, ip: name }
: { type: 2, value: name } ]
} ]
const pems = require('selfsigned').generate([ { name: 'commonName', value: name } ]
, { extensions, keySize: 2048, algorithm: 'sha256' })
!fs.existsSync(dir) && mkdirp.sync(dir)
fs.writeFileSync(path.join(dir, 'key.pem'), pems.private)
fs.writeFileSync(path.join(dir, 'cert.pem'), pems.cert)
console.log(`Created TLS certificate with fingerprint ${ pems.fingerprint } in ${ dir }`)
return { key: pems.private, cert: pems.cert }
}
let location;
try {
data = JSON.parse(event.data);
} catch (error) {
console.log('Error parsing Wiki data', error);
return;
}
if (data.type !== 'edit') {
return;
}
const ipAddress = data.user;
if (!data || !isIp(ipAddress)) {
return;
}
try {
location = await getLocation(ipAddress, data);
} catch (error) {
console.log('IP Location Error:', error);
return;
}
if (!location || location.error) {
console.log('IP Location Error:', {location});
return;
}
const item = {
function submit() {
if(isIP(ip)) {
setReload()
} else message.error("Not a valid IP address");
}
const formatDestAddress = (ip: string) => {
const hasPort = !isNaN(ip.split(':').pop() || ('' as any))
if (isIp.v4(ip) && hasPort) {
return ip
}
return urlFormat({ hostname: ip, port: WEBSOCKET_PORT_DEFAULT })
}
export const isIP = (ip: string): boolean => isIp(ip)
normalize(typeHash, hash) {
const ip = hash.IP;
if (isIp.v6(ip)) {
hash.IP = `[${ip}]`;
}
const reservedPorts = (hash.ReservedPorts || []).map(port => ({
name: port.Label,
port: port.Value,
to: port.To,
isDynamic: false,
}));
const dynamicPorts = (hash.DynamicPorts || []).map(port => ({
name: port.Label,
port: port.Value,
to: port.To,
isDynamic: true,
}));
function isIP (string) {
if (isIpLib.v4(string)) return 4
else if (isIpLib.v6(string)) return 6
else return 0
}
normalize(typeHash, hash) {
const ip = hash.IP;
if (isIp.v6(ip)) {
hash.IP = `[${ip}]`;
}
return this._super(...arguments);
},
});