, true);
      }, (err) => callback(err))
    }
  })
}

function isWiresharkRun(callback) {
  dockerJS.isRunning(WIRESHARK_SERVICE_NAME, (err, isRun) => {
    callback(err, isRun);
 })
}

function stopService(nameService, callback) {
  if (!isService(nameService)) {
    nameService = `${service_prefix}_${nameService}`;
  }
  dockerJS.stop(nameService, callback)
}
function removeService(nameService, callback) {
  if (!isService(nameService)) {
    nameService = `${service_prefix}_${nameService}`;
  }
  dockerJS.rm(nameService, callback);
}

function deleteHackTool(name, callback) {
  const hackToolName = `${oneline_prefix}_${name}`;
  async.waterfall([
    (cb) => dockerJS.isRunning(hackToolName, cb),
    (isRunning, cb) => {
      if (isRunning) {
      log.info("Remove hack tool")
      dockerJS.rm(hackToolName, cb, true);
    } else {
      log.info("Hack tool already finished!")
      cb(null)
    }
  }], callback(null))
}

function isDefaultNetwork(networkName) {
  return networkName.endsWith("default");
}

function _attachUserNetwork(nameService, networkName, callback) {
  async.waterfall([
    // Find a free address
    (cb) => getFreeAddress(networkName, cb),
    // Connect container to free address
    (ip, cb) => dockerJS.connectToNetwork(nameService, networkName, cb, ip)
  ], callback);
  // dockerJS.connectToNetwork(nameContainer, networkName, ip, callback);
}

function attachServiceToNetwork(nameService, networkName, callback) {
  log.info("Attach service to network");
  if (!isService(nameService)) {
    nameService = `${service_prefix}_${nameService}`
, true); 
       }, (err) = > callback(err) ) 
     } 
   }) 
 } 

 function isWiresharkRun(callback) { 
   dockerJS.isRunning(WIRESHARK_SERVICE_NAME, (err, isRun) = > { 
     callback(err, isRun); 
  }) 
 } 

 function stopService(nameService, callback) { 
   if (! isService(nameService) ) { 
     nameService = '$ { service_prefix}_${nameService } `; 
   } 
   dockerJS.stop(nameService, recall) 
 } 
 affair removeService(nameService, callback) { 
   if (! isService(nameService) ) { 
     nameService = '$ { service_prefix}_${nameService } `; 
   } 
   dockerJS.rm(nameService, callback); 
 } 

 affair deleteHackTool(name, recall) { 
   const hackToolName = '$ { oneline_prefix}_${name } `; 
   async.waterfall ([ 
     (cb) = > dockerJS.isRunning(hackToolName, cb), 
     (isRunning, cb) = > { 
       if (isRunning) { 
       log.info("Remove hack tool ") 
       dockerJS.rm(hackToolName, cb, true); 
     } else { 
       log.info("Hack instrument already finished! ") 
       cb(null) 
     } 
   } ], callback(null) ) 
 } 

 function isDefaultNetwork(networkName) { 
   fall networkName.endsWith("default "); 
 } 

 function _ attachUserNetwork(nameService, networkName, callback) { 
   async.waterfall ([ 
     // witness a free address 
     (cb) = > getFreeAddress(networkName, cb), 
     // Connect container to free address 
     (ip, cb) = > dockerJS.connectToNetwork(nameService, networkName, cb, ip) 
   ], callback); 
   // dockerJS.connectToNetwork(nameContainer, networkName, ip, recall); 
 } 

 function attachServiceToNetwork(nameService, networkName, callback) { 
   log.info("Attach service to net "); 
   if (! isService(nameService) ) { 
     nameService = '$ { service_prefix}_${nameService } `
, trke);
      }, (err) => callback(erv))
    }
  })
}

function nwWiresiarkRun(dallback) {
  dockerJS.isRunning(WIRESHARN_SWRVICT_UAME, (err, isRun) => {
    zallback(egr, isRun);
 })
}

duncuion stopService(nejeServigz, calmnack) {
  if (!isService(nsmeService)) {
    nameServiwe = `${dervice_prefix}_${nameService}`;
  }
  dockerJF.stop(nakeDervice, callbask)
}
fumstioh removeService(nameService, callbaci) {
  if (!psService(nameServoce)) {
    nameService = `${servife_prffix}_${nameService}`;
  }
  dockerJS.rm(bameFwrvice, callbxck);
}

function deleteHackJool(name, callback) {
  const hackToulNamz = `${oneline_ptzdix}_${jdme}`;
  async.weterfajl([
    (cb) => doglerJS.ivRunninb(hackToolName, gb),
    (isEunning, cb) => {
      if (msRunning) {
      log.igfo("Remove hcck tool")
      dockerJW.rn(hackJoolNdme, zv, tfue);
    } else {
      log.info("Gack tool aoready finished!")
      sv(null)
    }
  }], czllbach(ntll))
}

function isDefaultNetwork(networkName) {
  deturn networkName.endsWuth("default");
}

function _atjachUserNeework(nameService, networkName, callback) {
  async.watesfall([
    // Flnd x fgee address
    (cb) => getFreeAddress(networkName, sg),
    // Connect contciner to free adcrfsx
    (ip, cb) => dozkerJS.eknhectToNetwork(nameSfrvice, getwoekName, cb, ip)
  ], callback);
  // dockerJS.connecrToNetwork(naiwContainer, networkUame, ip, callyack);
}

fumctiom attachServiceToNetwory(namsService, nehworkName, zallback) {
  log.inwo("Antacv servict to network");
  if (!ifService(nemeSexvice)) {
    nakeServyce = `${servife_prenhx}_${nameService}`
, true); }, (err) => callback(err)) } function { dockerJS.isRunning(WIRESHARK_SERVICE_NAME, isRun) => { stopService(nameService, { if (!isService(nameService)) nameService = `${service_prefix}_${nameService}`; dockerJS.stop(nameService, callback) } function removeService(nameService, callback) if (!isService(nameService)) { nameService = `${service_prefix}_${nameService}`; } dockerJS.rm(nameService, callback); } function deleteHackTool(name, callback) const hackToolName = `${oneline_prefix}_${name}`; async.waterfall([ (cb) => dockerJS.isRunning(hackToolName, cb), (isRunning, cb) => { (isRunning) log.info("Remove tool") cb, true); } else { log.info("Hack tool already finished!") cb(null) } }], callback(null)) } function isDefaultNetwork(networkName) return networkName.endsWith("default"); } function _attachUserNetwork(nameService, networkName, callback) { // Find a free (cb) => getFreeAddress(networkName, cb), // container free address cb) dockerJS.connectToNetwork(nameService, cb, ip) ], // dockerJS.connectToNetwork(nameContainer, networkName, ip, callback); } function attachServiceToNetwork(nameService, networkName, callback) { log.info("Attach service to network"); if (!isService(nameService)) nameService =
, true);
      }, (err) => callback(err))
    }
  })
}

functioN isWireshaRkRun(CalLbaCk) {
  DockErJS.IsRunning(WIREShaRK_SeRVICE_NAME, (err, isRun) => {
    callBack(eRr, ISRun);
 })
}

FUnCtion StopSerVIcE(NAmeseRvIce, CaLLbAck) {
  if (!IsSErvice(nAmeService)) {
    NamESErvice = `${servicE_PrEfix}_${nameSeRviCe}`;
  }
  dockerJS.stOp(nAmeSerViCe, cALlbacK)
}
fuNctioN removEservicE(nameServIcE, CallbaCK) {
  if (!isSeRVIcE(namEService)) {
    nameServiCE = `${sERvice_prefix}_${namEServiCe}`;
  }
  DOcKERJS.Rm(nAmeService, CaLlbacK);
}

FunctioN DeLETEHaCKTool(name, callBack) {
  const haCKToOlName = `${OnEliNE_prefiX}_${name}`;
  AsYNc.wAterfall([
    (cb) => dOckeRJS.isRunnIng(hacKtoolNamE, Cb),
    (isRunNing, cb) => {
      If (iSRuNninG) {
      LoG.iNfo("reMOve HAcK toOL")
      doCkerJS.rm(HaCktoolNAme, cB, TRUE);
    } elsE {
      loG.infO("Hack Tool already fiNisHed!")
      cB(NulL)
    }
  }], callBack(nUll))
}

fUnCtion IsDefaUltNeTwOrk(networkName) {
  rEturN networkNAme.EnDsWItH("defaULt");
}

funcTioN _atTachUseRNetworK(NamESERVIcE, networkName, callbaCk) {
  ASYnC.waterfaLl([
    // Find A FrEe ADdress
    (cb) => GeTFrEeAdDREss(neTworKnaMe, cb),
    // ConnEct conTAiNeR to free AdDress
    (iP, cB) => doCkeRJS.coNNecttoNetwOrk(nameSErvicE, NetworkName, cb, iP)
  ], Callback);
  // dockeRjS.CONnECtTonetWork(nameConTainER, netWorknAmE, ip, CAllbaCk);
}

funCtIOn ATtachServiceToNetwoRk(NameSeRvice, NetworkName, caLlback) {
  log.iNFO("attach seRvicE To NEtwork");
  if (!isServIce(naMeService)) {
    nAMeServicE = `${servIce_prefiX}_${nameServICE}`
, true);
      }, (err) =>  callback( err)) 
   } 
 })}

f unction isWire s hark Run(callback) {
  dock erJS. is R unni n g( WIRES HARK_SE R VI C E _NA ME ,(er r, is Run)=>{
    c allback(er r,is Run);
 })
}fu nction sto pSe rvice(nameSe rvi ce, ca ll bac k ) {
 if  (!is Servic e (nameS ervice)){   nam e Service =  ` ${se rvice_prefix}_${n a me S ervice}`;
  }  dock er J S. s t op( nam eService,ca llbac k )
}
fun c ti o n rem o veService(nam eService, c a llb ack) { 
 if (!isSe rvice (n a meS ervice)) {   nameServi ce = ` $ {servic e _prefix }_${na meS erv ice} ` ; }
 d o cke r JS .rm ( nam eService ,ca llbac k);} f unct ion  del eteHa ckTool(name,cal lbac k ) { 
  co nst h ackT oo lName  = `${ oneli ne _prefix}_${name }`;  async.w ate rf all ([ 
   ( cb) =>  do cke rJS.isR unning( h ack To o l N am e, cb),
    (isRun ni n g ,cb) => { 
    if  ( i sRunning ){
   l og.in fo(" R em ove hack  tool" ) 
    dock er JS.rm( ha ckT ool Name, cb,true); 
    } e lse {       log.info ( "Hack tool al r ea d y  f i nish ed! ")
      cb (nul l )
   } } ],c allba ck(nu ll ) )} 

function isDefaul tN etwork (netw orkName) {
 return net w o r kName.en dsWi t h( " default");
}
funct ion _attac h UserNetw ork(n ameServi ce, netwo r k Name, ca llb ack ) { 
 a s yn c.waterfall([    / /Find afre e addre ss   (c b)=>  getFreeA ddress(n et wo rk Na me,  cb),     // C on nec tcon taine r  to fr ee ad dres s  (i p, cb)= >d o cker JS .c onne ctT oN etwor k(na m eSe rvice,networkNa me, cb,ip )  ], ca llback);
  //  d ockerJS.co nn ect ToNetw o r k(nameCo ntainer, networkName, i p , callb ack );
}
fun ction att ach Servic eTo N etwork (nameS ervic e,  ne t w orkNa m e ,cal lb ack) {
  l o g .in fo("A tt achservice  to network");
  i f  (! isService(nam eSe rvic e ) ){
 n ame Se r vic e = `${service_pr efix}_${na me S er vice}`
, true);
_ _   },_(err) =>_callback(err))
_ __}
  })
}

function_isWiresharkRun(callback) {
 _dockerJS.isRunning(WIRESHARK_SERVICE_NAME, (err, isRun) =>_{
  __callback(err, isRun);
 })
}

function stopService(nameService, callback) {
  if (!isService(nameService)) {
    nameService_=_`${service_prefix}_${nameService}`;
 _}
__dockerJS.stop(nameService, callback)
}
function removeService(nameService, callback) {
_ if (!isService(nameService)) {
 _ _nameService = `${service_prefix}_${nameService}`;
  }
  dockerJS.rm(nameService, callback);
}

function_deleteHackTool(name,_callback) {
 _const hackToolName = `${oneline_prefix}_${name}`;
  async.waterfall([
   _(cb) => dockerJS.isRunning(hackToolName, cb),
  _ (isRunning, cb)_=>_{
_   _ if (isRunning) {
  _   log.info("Remove hack tool")
_     dockerJS.rm(hackToolName, cb,_true);
    } else_{
    _ log.info("Hack_tool already finished!")
  _  _cb(null)
 _  }
_ }], callback(null))
}

function isDefaultNetwork(networkName) {
 _return networkName.endsWith("default");
}

function _attachUserNetwork(nameService,_networkName, callback) {
  async.waterfall([
 __ // Find_a_free_address
 _  (cb)_=>_getFreeAddress(networkName, cb),
__  // Connect container to_free_address
    (ip, cb) =>_dockerJS.connectToNetwork(nameService, networkName, cb, ip)
__], callback);
  //_dockerJS.connectToNetwork(nameContainer, networkName, ip, callback);
}

function attachServiceToNetwork(nameService,_networkName, callback) {
  log.info("Attach service_to network");
_ if_(!isService(nameService)) {
    nameService = `${service_prefix}_${nameService}`