From c273078376d5aa394e871e7436b8e770b0c3f4a0 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Tue, 11 Jul 2017 18:48:29 +0200 Subject: Added ratelimiting of handshake messages --- src/device.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/device.go') diff --git a/src/device.go b/src/device.go index 12d1ed9..2a2ad62 100644 --- a/src/device.go +++ b/src/device.go @@ -31,9 +31,10 @@ type Device struct { signal struct { stop chan struct{} } - underLoad int32 // used as an atomic bool - peers map[NoisePublicKey]*Peer - mac MACStateDevice + underLoad int32 // used as an atomic bool + ratelimiter Ratelimiter + peers map[NoisePublicKey]*Peer + mac MACStateDevice } func (device *Device) SetPrivateKey(sk NoisePrivateKey) { @@ -66,6 +67,7 @@ func NewDevice(tun TUNDevice, logLevel int) *Device { device.mtu = tun.MTU() device.peers = make(map[NoisePublicKey]*Peer) device.indices.Init() + device.ratelimiter.Init() device.routingTable.Reset() // listen @@ -99,6 +101,7 @@ func NewDevice(tun TUNDevice, logLevel int) *Device { go device.RoutineReadFromTUN(tun) go device.RoutineReceiveIncomming() go device.RoutineWriteToTUN(tun) + go device.ratelimiter.RoutineGarbageCollector(device.signal.stop) return device } -- cgit v1.2.3