mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: using proper timeouts in http and https proxies (fixes #26)
This commit is contained in:
parent
e0102ec9e0
commit
8081bf2d53
1 changed files with 13 additions and 2 deletions
|
@ -25,6 +25,11 @@ import (
|
|||
"github.com/inconshreveable/go-vhost"
|
||||
)
|
||||
|
||||
const (
|
||||
httpReadTimeout = 5 * time.Second
|
||||
httpWriteTimeout = 10 * time.Second
|
||||
)
|
||||
|
||||
type HTTPProxy struct {
|
||||
Name string
|
||||
Address string
|
||||
|
@ -144,8 +149,10 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scrip
|
|||
}
|
||||
|
||||
p.Server = http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", p.Address, proxyPort),
|
||||
Handler: p.Proxy,
|
||||
Addr: fmt.Sprintf("%s:%d", p.Address, proxyPort),
|
||||
Handler: p.Proxy,
|
||||
ReadTimeout: httpReadTimeout,
|
||||
WriteTimeout: httpWriteTimeout,
|
||||
}
|
||||
|
||||
if p.sess.Firewall.IsForwardingEnabled() == false {
|
||||
|
@ -279,6 +286,10 @@ func (p *HTTPProxy) httpsWorker() error {
|
|||
}
|
||||
|
||||
go func(c net.Conn) {
|
||||
now := time.Now()
|
||||
c.SetReadDeadline(now.Add(httpReadTimeout))
|
||||
c.SetWriteDeadline(now.Add(httpWriteTimeout))
|
||||
|
||||
tlsConn, err := vhost.TLS(c)
|
||||
if err != nil {
|
||||
log.Warning("Error reading SNI: %s.", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue