validate : function (value) {
				var pass = ipRegex({exact : true}).test(value) ||
				           value.match(/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/);
				if (pass) {
					return true;
				} else {
					return "Please use valid IP or hostname";
				}
			},
module.exports = function ipFilter (ip, patterns, noStrict) {
  noStrict = typeof noStrict === 'boolean' ? noStrict : false

  if (!noStrict && !ipRegex().test(ip)) {
    throw new Error('ip-filter expect only valid IPv4/IPv6 IPs')
  }

  var match = noStrict
    ? isMatch(patterns)(ip)
    : isMatch(toPath(patterns))(toPath(ip))

  return match ? ip : null
}
Exemple #3
0
function _waitForIp(deployId){
    console.debug('waiting for nameserver ip to become available')
    let res = "";
    try{
        while(!ipRegex({exact: true}).test(res)){
            let out = execSync(`kubectl get svc ${deployId} --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}"`);    
            res = out.toString();  
        }
    }catch(err){
        console.debug(err.toString());
        throw new Error('failed to fetch ip from kubectl');
    }
    console.debug(`IP for ${deployId} is ${res}`);
    return res;
}
Exemple #4
0
module.exports = function ipFilter (ip, patterns, options) {
  if (typeof ip !== 'string') {
    throw new TypeError('ip-filter: expect `ip` to be a string')
  }

  options = typeof options === 'object' ? options : {}
  options.strict = typeof options.strict === 'boolean' ? options.strict : true

  if (options.strict && !ipRegex().test(ip)) {
    throw new Error('ip-filter: expect only valid IPs when `opts.strict` mode')
  }

  var id = options.strict ? tofp(ip) : ip
  patterns = options.strict ? tofp(patterns) : patterns

  return isMatch(patterns, options)(id) ? ip : null
}
Exemple #5
0
"use strict";var ipRegex=require("ip-regex"),ip=module.exports=function(e){return ipRegex({exact:!0}).test(e)};ip.v4=function(e){return ipRegex.v4({exact:!0}).test(e)},ip.v6=function(e){return ipRegex.v6({exact:!0}).test(e)};