How to use the isV6Format function from ip

Find comprehensive JavaScript ip.isV6Format code examples handpicked from public code repositorys.

243
244
245
246
247
248
249
250
251
252
await exec(`sudo iptables -w -t nat -F ${chain}`).catch((err) => {});
await exec(`sudo ip6tables -w -t nat -F ${chain}`).catch((err) => {});
for (let i in dnsServers) {
  const dnsServer = dnsServers[i];
  let bin = "iptables";
  if (!ipTool.isV4Format(dnsServer) && ipTool.isV6Format(dnsServer)) {
    bin = "ip6tables";
  }
  // round robin rule for multiple dns servers
  if (i == 0) {
fork icon117
star icon463
watch icon0

+ 4 other calls in file

98
99
100
101
102
103
104
105
106
107
// do not record if *host* is an IP
if (validator.isIP(host)) {
  return;
}

if ((iptool.isV4Format(destIP) || iptool.isV6Format(destIP)) && isDomainValid(host)) {
  const domain = formulateHostname(host);
  await dnsTool.addDns(destIP, domain, (config && config.bro && config.bro.dns && config.bro.dns.expires) || 100000);
  await dnsTool.addReverseDns(domain, [destIP], (config && config.bro && config.bro.dns && config.bro.dns.expires) || 100000);
}
fork icon117
star icon463
watch icon0

336
337
338
339
340
341
342
343
344
345
  }
} else {
  if (!isDomainValid(obj["query"]))
    return;

  const answers = obj['answers'].filter(answer => !firewalla.isReservedBlockingIP(answer) && (iptool.isV4Format(answer) || iptool.isV6Format(answer)));
  const cnames = obj['answers'].filter(answer => !firewalla.isReservedBlockingIP(answer) && !iptool.isV4Format(answer) && !iptool.isV6Format(answer) && isDomainValid(answer)).map(answer => formulateHostname(answer));
  const query = formulateHostname(obj['query']);

  if (sysManager.isSearchDomain(query) || sysManager.isLocalDomain(query))
fork icon117
star icon463
watch icon0

33
34
35
36
37
38
39
40
41
42
43
const unsecured_https_proxy_agent = HTTPS_PROXY ?
    createHttpsProxyAgent({ ...url.parse(HTTPS_PROXY), rejectUnauthorized: false }) : null;


const no_proxy_list =
    (NO_PROXY ? NO_PROXY.split(',') : []).map(addr => {
        if (ip.isV4Format(addr) || ip.isV6Format(addr)) {
            return {
                kind: 'IP',
                addr
            };
fork icon68
star icon227
watch icon0

+ 2 other calls in file

8
9
10
11
12
13
14
15
16
17
18
19
  if (agent.startsWith('https')) return httpsAgent;
  return httpAgent;
};


const defaultIpChecker = ip => {
  if (isV4Format(ip) || isV6Format(ip)) {
    return !isPrivate(ip);
  }


  return true;
fork icon2
star icon19
watch icon0

43
44
45
46
47
48
49
50
51
52
  const simpleLogSplit = msg.split("-");
  const ipAddress = simpleLogSplit[1];
  if (
    msg.match(/(GET|POST|PUT|DELETE|CONNECT|HEAD|OPTIONS|TRACE)\s\/.*\s\-/)
  ) {
    if (ip.isV4Format(ipAddress.trim()) || ip.isV6Format(ipAddress.trim())) {
      globals.userPassedLoggerChallenge = true;
    }
  }
}
fork icon21
star icon6
watch icon0

94
95
96
97
98
99
100
101
102
103
 * @returns {boolean}
 */
module.exports.isValidContact = function(contact, loopback) {
  const [, info] = contact;
  const isValidAddr = ip.isV4Format(info.hostname) ||
                      ip.isV6Format(info.hostname) ||
                      ip.isPublic(info.hostname);
  const isValidPort = info.port > 0;
  const isAllowedAddr = ip.isLoopback(info.hostname) ? !!loopback : true;

fork icon20
star icon1
watch icon0

+ 2 other calls in file

671
672
673
674
675
676
677
678
679
680
// A note on IPv6 addresses:
// hostHeader will always contain the brackets denoting
// an IPv6-address in URLs,
// these are removed from the hostname in url.parse(),
// so we have the pure IPv6-address in hostname.
if (ip.isV4Format(hostname) || ip.isV6Format(hostname)) {
  return true;
}
// always allow localhost host, for convience
if (hostname === 'localhost') {
fork icon0
star icon1
watch icon0

+ 2 other calls in file

888
889
890
891
892
893
894
895
896
897
// so we have the pure IPv6-address in hostname.
// always allow localhost host, for convenience (hostname === 'localhost')
// allow hostname of listening address  (hostname === this.hostname)
const isValidHostname =
  ip.isV4Format(hostname) ||
  ip.isV6Format(hostname) ||
  hostname === 'localhost' ||
  hostname === this.hostname;

if (isValidHostname) {
fork icon0
star icon0
watch icon1

+ 3 other calls in file

187
188
189
190
191
192
193
194
195
if (!contact) {
  return false;
}

var isValidAddr = ip.isV4Format(contact.address) ||
                  ip.isV6Format(contact.address) ||
                  ip.isPublic(contact.address);
var isValidPort = contact.port > 0;
var isAllowedAddr = ip.isLoopback(contact.address) ? !!loopback : true;
fork icon0
star icon0
watch icon0

545
546
547
548
549
550
551
552
553

// always allow requests with explicit IPv4 or IPv6-address.
// A note on IPv6 addresses: hostHeader will always contain the brackets denoting
// an IPv6-address in URLs, these are removed from the hostname in url.parse(),
// so we have the pure IPv6-address in hostname.
if (ip.isV4Format(hostname) || ip.isV6Format(hostname)) return true;

// always allow localhost host, for convience
if (hostname === 'localhost') return true;
fork icon0
star icon0
watch icon0

+ 3 other calls in file