mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -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"
|
"github.com/inconshreveable/go-vhost"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
httpReadTimeout = 5 * time.Second
|
||||||
|
httpWriteTimeout = 10 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
type HTTPProxy struct {
|
type HTTPProxy struct {
|
||||||
Name string
|
Name string
|
||||||
Address string
|
Address string
|
||||||
|
@ -144,8 +149,10 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scrip
|
||||||
}
|
}
|
||||||
|
|
||||||
p.Server = http.Server{
|
p.Server = http.Server{
|
||||||
Addr: fmt.Sprintf("%s:%d", p.Address, proxyPort),
|
Addr: fmt.Sprintf("%s:%d", p.Address, proxyPort),
|
||||||
Handler: p.Proxy,
|
Handler: p.Proxy,
|
||||||
|
ReadTimeout: httpReadTimeout,
|
||||||
|
WriteTimeout: httpWriteTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.sess.Firewall.IsForwardingEnabled() == false {
|
if p.sess.Firewall.IsForwardingEnabled() == false {
|
||||||
|
@ -279,6 +286,10 @@ func (p *HTTPProxy) httpsWorker() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
go func(c net.Conn) {
|
go func(c net.Conn) {
|
||||||
|
now := time.Now()
|
||||||
|
c.SetReadDeadline(now.Add(httpReadTimeout))
|
||||||
|
c.SetWriteDeadline(now.Add(httpWriteTimeout))
|
||||||
|
|
||||||
tlsConn, err := vhost.TLS(c)
|
tlsConn, err := vhost.TLS(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warning("Error reading SNI: %s.", err)
|
log.Warning("Error reading SNI: %s.", err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue