MCPcopy
hub / github.com/bettercap/bettercap / Stop

Method Stop

modules/http_proxy/http_proxy_base.go:436–464  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434}
435
436func (p *HTTPProxy) Stop() error {
437 if p.Script != nil {
438 if p.Script.Plugin.HasFunc("onExit") {
439 if _, err := p.Script.Call("onExit"); err != nil {
440 log.Error("Error while executing onExit callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
441 }
442 }
443 }
444
445 if p.doRedirect && p.Redirection != nil {
446 p.Debug("disabling redirection %s", p.Redirection.String())
447 if err := p.Sess.Firewall.EnableRedirection(p.Redirection, false); err != nil {
448 return err
449 }
450 p.Redirection = nil
451 }
452
453 p.Sess.UnkCmdCallback = nil
454
455 if p.isTLS {
456 p.isRunning = false
457 p.sniListener.Close()
458 return nil
459 } else {
460 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
461 defer cancel()
462 return p.Server.Shutdown(ctx)
463 }
464}

Callers

nothing calls this directly

Calls 6

DebugMethod · 0.95
ShutdownMethod · 0.80
EnableRedirectionMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected