viewer/molochparser.js
// Have just a single Ip, create obj for it
Have just a single Ip, create obj for it
Have just a single Ip create obj for it
function parseSingleIp (exp, singleDbField, singleIp, singlePort) {
    let singleObj;
    if (typeof (singlePort) === 'string' && singlePort.match(/[^0-9]/)) {
      throw singlePort + ' not a valid singlePort';
    }
    if (singleIp !== undefined) {
      const colon = singleIp.indexOf(':');
      if ((colon === -1 && singleIp.match(/[^.0-9/]/)) || 
          (colon !== -1 && singleIp.match(/[^a-fA-F:0-9/]/)) || 
          singleIp.match(/\/.*[^0-9]/)) { 
        throw singleIp + ' not a valid ip';
      }
      singleObj = { term: {} };
      singleObj.term[singleDbField] = singleIp;
    }
    if (singlePort !== -1) {
      const expInfo = getFieldInfo(yy, exp);
      if (expInfo.portField) {
        singleObj = { bool: { filter: [singleObj, { term: {} }] } };
        singleObj.bool.filter[1].term[expInfo.portField] = singlePort;
      } else {
        throw exp + " doesn't support port";
      }
      if (singleIp === undefined) {
        singleObj = singleObj.bool.filter[1];
      }
    }
    return singleObj;
  }
function parseSingleIp ( exp , singleDbField , singleIp , singlePort ) { let singleObj ; if ( typeof ( singlePort ) === 'string' && singlePort . match ( / [^0-9] / ) ) { throw singlePort + ' not a valid singlePort' ; } if ( singleIp !== undefined ) { const colon = singleIp . indexOf ( ':' ) ; if ( ( colon === - 1 && singleIp . match ( / [^.0-9/] / ) ) || ( colon !== - 1 && singleIp . match ( / [^a-fA-F:0-9/] / ) ) || singleIp . match ( / \/.*[^0-9] / ) ) { throw singleIp + ' not a valid ip' ; } singleObj = { term : { } } ; singleObj . term [ singleDbField ] = singleIp ; } if ( singlePort !== - 1 ) { const expInfo = getFieldInfo ( yy , exp ) ; if ( expInfo . portField ) { singleObj = { bool : { filter : [ singleObj , { term : { } } ] } } ; singleObj . bool . filter [ 1 ] . term [ expInfo . portField ] = singlePort ; } else { throw exp + " doesn't support port" ; } if ( singleIp === undefined ) { singleObj = singleObj . bool . filter [ 1 ] ; } } return singleObj ; }
Have just a single Ip, create obj for it
Have just a single Ip create obj for it
// IP4 // IP6 // CIDR