mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
fix; handling http.proxy stop gracefully
This commit is contained in:
parent
d87bf8a3ba
commit
7b42da1bf3
1 changed files with 5 additions and 1 deletions
|
@ -1,9 +1,11 @@
|
||||||
package modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/elazarl/goproxy"
|
"github.com/elazarl/goproxy"
|
||||||
|
|
||||||
|
@ -191,7 +193,9 @@ func (p *HttpProxy) Start() error {
|
||||||
func (p *HttpProxy) Stop() error {
|
func (p *HttpProxy) Stop() error {
|
||||||
if p.Running() == true {
|
if p.Running() == true {
|
||||||
p.SetRunning(false)
|
p.SetRunning(false)
|
||||||
p.server.Shutdown(nil)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
p.server.Shutdown(ctx)
|
||||||
if p.redirection != nil {
|
if p.redirection != nil {
|
||||||
log.Debug("Disabling redirection %s", p.redirection.String())
|
log.Debug("Disabling redirection %s", p.redirection.String())
|
||||||
if err := p.Session.Firewall.EnableRedirection(p.redirection, false); err != nil {
|
if err := p.Session.Firewall.EnableRedirection(p.redirection, false); err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue