limit acceptance rate on peer connections
The main purpose of this is to set an upper bound on the rate at which an attacker might execute a brute force attack on the weave password. No need to get clever or precise here. Closes #837.
This commit is contained in:
1 parent
2a244e5699
commit
044992eea0
2 files changed
+22
-10
No files matched your search
+9
-1
@@ -13,11 +13,18 @@ import (
|
||||
"code.google.com/p/gopacket/layers"
|
||||
)
|
||||
|
||||
const macMaxAge = 10 * time.Minute // [1]
|
||||
const (
|
||||
macMaxAge = 10 * time.Minute // [1]
|
||||
tcpAcceptDelay = 1 * time.Millisecond // [2]
|
||||
)
|
||||
|
||||
// [1] should be greater than typical ARP cache expiries, i.e. > 3/2 *
|
||||
// /proc/sys/net/ipv4_neigh/*/base_reachable_time_ms on Linux
|
||||
|
||||
// [2] time to wait between accepting tcp connections. This guards
|
||||
// against brute-force attacks on the password when encryption is in
|
||||
// use. It is also a basic DoS defence.
|
||||
|
||||
type LogFrameFunc func(string, []byte, *layers.Ethernet)
|
||||
|
||||
type Config struct {
|
||||
@@ -199,6 +206,7 @@ func (router *Router) listenTCP(localPort int) {
|
||||
continue
|
||||
}
|
||||
router.acceptTCP(tcpConn)
|
||||
time.Sleep(tcpAcceptDelay)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user