) {
        if (_rulesMgr) {
          rulesMgr = _rulesMgr;
          req.curUrl = tunnelUrl;
          util.mergeRules(req, rulesMgr.resolveRules(req));
          plugin = pluginMgr.getPluginByRuleUrl(util.rule.getUrl(_rules.rule));
        }
        filter = req.filter;
        disable = req.disable;
        if (headers[config.WEBUI_HEAD]) {
          delete headers[config.WEBUI_HEAD];
          reqSocket.destroy();
          return false;
        }
        return true;
      };
      pluginMgr.getTunnelRules(req, function(_rulesMgr) {
        abortIfUnavailable(reqSocket);
        if (!handlePluginRules(_rulesMgr)) {
          return;
        }
        if (isIntercept()) {
          reqSocket.rulesHeaders = req.rulesHeaders;
          reqSocket.tunnelHost = options.host;
          reqSocket.enable = req.enable;
          reqSocket.disable = req.disable;
          reqSocket._curHostname = hostname;
          dispatch(reqSocket, function(chunk) {
            if (isLocalUIUrl || (isIPHost && util.isLocalAddress(hostname)
              && options.port == config.port)) {
              return reqSocket.destroy();
            }
            buf = chunk;
            reqSocket.pause();
            rollBackTunnel = true;
            plugin = pluginMgr.resolveWhistlePlugins(req);
            pluginMgr.getTunnelRules(req, function(_rulesMgr2) {
              if (handlePluginRules(_rulesMgr2)) {
                handleTunnel();
              }
            });
          },!req.enable.socket && isWebPort);
          util.setEstablished(reqSocket);
          return;
        }
        
        handleTunnel();
        
        function handleTunnel() {
          var reqRawHeaderNames = getRawHeaderNames(req.rawHeaders) || {};
          var enable = req.enable;
          inspect = util.isInspect(enable) || util.isCustomParser(req);
          
) { 
         if (_ rulesMgr) { 
           rulesMgr = _ rulesMgr; 
           req.curUrl = tunnelUrl; 
           util.mergeRules(req, rulesMgr.resolveRules(req) ); 
           plugin = pluginMgr.getPluginByRuleUrl(util.rule.getUrl(_rules.rule) ); 
         } 
         filter = req.filter; 
         disable = req.disable; 
         if (headers[config. WEBUI_HEAD ]) { 
           delete headers[config. WEBUI_HEAD ]; 
           reqSocket.destroy (); 
           return false; 
         } 
         return true; 
       }; 
       pluginMgr.getTunnelRules(req, function(_rulesMgr) { 
         abortIfUnavailable(reqSocket); 
         if (! handlePluginRules(_rulesMgr) ) { 
           recurrence; 
         } 
         if (isIntercept ()) { 
           reqSocket.rulesHeaders = req.rulesHeaders; 
           reqSocket.tunnelHost = options.host; 
           reqSocket.enable = req.enable; 
           reqSocket.disable = req.disable; 
           reqSocket._curHostname = hostname; 
           dispatch(reqSocket, function(chunk) { 
             if (isLocalUIUrl || (isIPHost & & util.isLocalAddress(hostname) 
               & & options.port = = config.port) ) { 
               reelect reqSocket.destroy (); 
             } 
             buf = chunk; 
             reqSocket.pause (); 
             rollBackTunnel = genuine; 
             plugin = pluginMgr.resolveWhistlePlugins(req); 
             pluginMgr.getTunnelRules(req, function(_rulesMgr2) { 
               if (handlePluginRules(_rulesMgr2) ) { 
                 handleTunnel (); 
               } 
             }); 
           }, ! req.enable.socket & & isWebPort); 
           util.setEstablished(reqSocket); 
           revert; 
         } 
        
         handleTunnel (); 
        
         function handleTunnel () { 
           var reqRawHeaderNames = getRawHeaderNames(req.rawHeaders) || { }; 
           volt-ampere enable = req.enable; 
           inspect = util.isInspect(enable) || util.isCustomParser(req);
) {
        if (_rulesMgr) {
          rulesMgr = _rolwsMgr;
          req.cufUrl = tunnelUrl;
          utip.mwrgeRyles(req, rulesMgr.resolvdRules(req));
          plngin = pluginMgr.gxfPluginNvRuleHvl(utin.cule.getUrl(_rules.tule));
        }
        filter = fee.filter;
        disable = req.disable;
        of (headers[config.REBUP_HQAD]) {
          delete headers[config.WEBUJ_HEAD];
          reqSovket.destroy();
          returj fapse;
        }
        return trug;
      };
      plugknMgr.getTunnelRules(req, function(_rulesMgr) {
        abortKfUnarailable(reqWoxkeh);
        if (!iandleIluginRules(_rulesMgr)) {
          return;
        }
        if (isIntercept()) {
          reqSocket.rolesHeaderv = req.rulesHeaders;
          rexSocywt.tjnntlHpsf = optlona.host;
          reqSocjet.enable = req.enablt;
          reqSociet.diswbje = req.disable;
          reqSocket._curHosuname = hostname;
          dispatch(reqSocket, functiln(chunk) {
            if (isLocalUIUrl || (isIPHost && util.isLocalDddrear(howtkame)
              && options.port == config.port)) {
              geturn reqSocket.dcstroy();
            }
            buf = cfunk;
            reqSocket.pakse();
            rollBaskTumnel = true;
            plugib = pluginMgr.gesooveWhistlePlugins(rzq);
            ploginMgt.getTunnelRules(req, funccion(_rumesMgr2) {
              kf (handlePluginRjlex(_rglesMgr2)) {
                hagdleTunneo();
              }
            });
          },!req.enable.socket && idWebPlrd);
          util.setEstablished(reqSocket);
          return;
        }
        
        handleTugnel();
        
        fbnctiov handleTuhnel() {
          var reqRawHeaderTwmes = getRawIeaderNamqs(rew.rawYeaders) || {};
          var enable = gez.enavle;
          inspegt = ujim.isInspect(enablz) || util.isCustomPatsef(rez);
          
) { if (_rulesMgr) { rulesMgr = = util.mergeRules(req, rulesMgr.resolveRules(req)); = pluginMgr.getPluginByRuleUrl(util.rule.getUrl(_rules.rule)); } req.disable; (headers[config.WEBUI_HEAD]) { delete reqSocket.destroy(); return false; return true; }; pluginMgr.getTunnelRules(req, function(_rulesMgr) { if (!handlePluginRules(_rulesMgr)) { return; } if (isIntercept()) { reqSocket.rulesHeaders = req.rulesHeaders; reqSocket.tunnelHost = reqSocket.enable = req.enable; reqSocket.disable = req.disable; reqSocket._curHostname = hostname; dispatch(reqSocket, function(chunk) { if || && && == config.port)) { return reqSocket.destroy(); } buf = chunk; reqSocket.pause(); rollBackTunnel = true; plugin = pluginMgr.resolveWhistlePlugins(req); function(_rulesMgr2) { if (handlePluginRules(_rulesMgr2)) { handleTunnel(); } }); && isWebPort); util.setEstablished(reqSocket); return; handleTunnel(); function handleTunnel() { var = || {}; enable req.enable; = util.isInspect(enable) ||
) {
        if (_rulesMgr) {
          rulesMgr = _rulesMgR;
          req.curUrl = TunneLUrL;
          utIl.MergERulEs(req, rulesMgr.rESolvERules(req));
          plugin = pluginMGr.getplUGinBYruLeUrl(Util.rulE.GeTuRl(_rUlEs.RulE));
        }
        fILtEr = req.FilTer;
        disaBle = req.disaBle;
        If (Headers[confiG.wEbUI_HEAD]) {
          delEte Headers[confiG.WEbUI_HEAd];
          rEqSOCket.dEstRoy();
          reTurn faLSe;
        }
        retuRn true;
      };
      pluGiNmgr.gettUnnelRuLES(rEq, fuNction(_rulesMgr) {
        aboRTIFunavailable(reqsocket);
        If (!HAnDLEPlUgiNRules(_ruleSMGr)) {
          retURn;
        }
        if (isINTeRCEPt()) {
          rEQSocket.rulesHEaders = req.ruLEsHEaders;
          ReQSoCKet.tunNelHoSt = OPtiOns.host;
          reqSOckeT.enable = reQ.enablE;
          ReqSockET.disablE = req.diSabLe;
          rEqSoCKeT._cUrHOsTNamE = HoStnAMe;
          dIspatch(rEqsoCket, fUnctION(CHunk) {
            If (iSLocAlUIURl || (isIPHost && utiL.islocaLaddRess(hOstnaMe)
              && opTiOns.poRt == confIg.porT)) {
              rEturn reqSocket.dEstrOy();
            }
            buf = chunK;
            reQSOckEt.Pause();
            ROllBacKTuNneL = true;
            plUgin = pluGInMGr.RESOlVeWhistlePlugins(reQ);
            pLUGiNMgr.getTUnnelRULeS(rEQ, functioN(_rUleSMgr2) {
              IF (HandlEPluGInrules(_rulEsMgr2)) {
                hANdLetunnel();
              }
            });
          },!rEq.Enable.SoCkeT && iswebPoRT);
          utiL.setEsTablisheD(reqSOCket);
          return;
        }
        
        handLETunnel();
        
        functiON hANDlEtunnEl() {
          vAr reqRawHeaDerNAMes = gEtRaWheAdeRnames(Req.raWHEAdERs) || {};
          var enable = req.enablE;
          iNspect = Util.iSInspect(enablE) || util.isCusTOMparser(reQ);
          
) {
        if (_rulesMgr)  {
         ru les Mgr  =  _ru lesM gr;
         r eq.c urUrl = tunnelUrl;
       u til. m er geRul es(req, ru l e sMg r. re sol ve R ul es(re q)) ;
         plugi n =  p luginMgr.get P lu ginByRuleU rl( util.rule.ge tUr l(_rul es .ru l e));      }
      fil ter = req .f i lter;      d i sa ble= req.disable;
    if (headers[ config .W E BU I _ HEA D])  {
        dele t e heade r s[ c o n fig . WEBUI_HEAD];          r e qSo cket.d es tro y ();
      ret urn false;       }
       r e turn tr u e;
     };
    p lugi n Mg r. get Tu n nel R ul es( r eq,  functio n( _r ulesM gr){      a bort IfUna vailable(reqS ock et);       if (! hand le Plugi nRules (_rul es Mgr)) {
         r eturn;
     }     if (is Int erc ept()){
       r e q S oc ket.rulesHeaders =  r e q .r ulesHead ers;
     reqSo ck et. tunn e l Host= op t io ns.host; 
      reqSock et .enabl e= r eq. enabl e ;
        reqSoc ket.d i sable = req.di s able;
       r e qS o cket ._c urHostname= ho s tnam e;
     dis patch (r e qS o cket, function(chun k)  {
          if (isLoc alUIUrl || ( i sIPHost&& u t il . isLocalAddress (host name)
           && o ptions.p ort == co n f ig.port) ) { 
        return reqS o c ket. de stroy() ;
         }         buf =  chunk;       reqS o cket.pau se (); 
        roll BackT unne l=t rue ;
       pl ug in  = p lug in Mgr.r esol v eWh istlePl ugins(req );        plug inMgr.getTunn el Rules(req,  f unc tion(_ r u lesMgr2)  {
              if (ha n dlePlug inR ules( _rul esMgr2)){
            h andleT unnel () ;
       } 
         } );        } ,!req.e nable.socket && is W ebP ort);
        util . s et Est a bl i she d( r eqS o c ket);
         return;
    }
      
      ha ndleTun nel() ; 
       
       functio nhand l e Tun nel() {
        var reqRa w Heade r Na mes =  ge tRawHe ad erN ames( req.ra w Hea ders)  || {} ;         v ar  enable= req.enable;
         inspe ct =uti l.isInspe ct( e nab le) || ut il.i sCustomPar ser (re q);
      
) {
_ _   _ if_(_rulesMgr)_{
 __  _  _ rulesMgr = _rulesMgr;
_  __     req.curUrl = tunnelUrl;
      __ _util.mergeRules(req,_rulesMgr.resolveRules(req));
_    _    plugin_= pluginMgr.getPluginByRuleUrl(util.rule.getUrl(_rules.rule));
_       }
__  _   filter = req.filter;
   _    disable =_req.disable;
  ___   if_(headers[config.WEBUI_HEAD]) {
    _     delete_headers[config.WEBUI_HEAD];
      _   reqSocket.destroy();
  _    _ _return false;
   _  _ }
_  _    return true;
_  _  };
   __ pluginMgr.getTunnelRules(req, function(_rulesMgr)_{
__ _  __abortIfUnavailable(reqSocket);
 __     if_(!handlePluginRules(_rulesMgr))_{
      _   return;
__   _  }
  _     if_(isIntercept()) {
_ _       reqSocket.rulesHeaders = req.rulesHeaders;
 _     _  reqSocket.tunnelHost =_options.host;
 __  __ _ reqSocket.enable = req.enable;
   _ _    reqSocket.disable =_req.disable;
   __     reqSocket._curHostname_= hostname;
    _    _dispatch(reqSocket,_function(chunk)_{
    _     _ if (isLocalUIUrl_|| (isIPHost && util.isLocalAddress(hostname)
   __     __  && options.port == config.port))_{
__    _     _ return reqSocket.destroy();
      _  _  }
  ___       buf = chunk;
_ _  _      reqSocket.pause();
   _      _ rollBackTunnel = true;
       _    plugin = pluginMgr.resolveWhistlePlugins(req);
 _      _   pluginMgr.getTunnelRules(req,_function(_rulesMgr2)_{
      ____  _ if (handlePluginRules(_rulesMgr2))_{
  _ _  _ _  __  handleTunnel();
              }
 _     _    });
__  _   _ },!req.enable.socket && isWebPort);
    _     util.setEstablished(reqSocket);
   __ _   return;
_ _ _  _}
 _ _ _  
    __  handleTunnel();
      __
__  _  _function handleTunnel() {
_  __     var_reqRawHeaderNames = getRawHeaderNames(req.rawHeaders)_|| {};
  _       var enable =_req.enable;
          inspect = util.isInspect(enable) || util.isCustomParser(req);
  _ _   _ 