From 272fb852e72ac282144fe8608fea62ab74b9549c Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Fri, 23 May 2014 04:04:31 +0000 Subject: Change the maximm handshake length to 8192 bytes. * handhake_ntor_test now is considerably more comprehensive. * The padding related constants in the spec were clarified. This breaks wireprotocol compatibility. --- replay_filter.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'replay_filter.go') diff --git a/replay_filter.go b/replay_filter.go index f5c64f8..5e98b89 100644 --- a/replay_filter.go +++ b/replay_filter.go @@ -78,7 +78,7 @@ func newReplayFilter() (filter *replayFilter, err error) { } // testAndSet queries the filter for buf, adds it if it was not present and -// returns if it has added the entry or not. +// returns if it has added the entry or not. This method is threadsafe. func (f *replayFilter) testAndSet(now int64, buf []byte) bool { hash := siphash.Hash(f.key[0], f.key[1], buf) @@ -102,7 +102,8 @@ func (f *replayFilter) testAndSet(now int64, buf []byte) bool { } // compactFilter purges entries that are too old to be relevant. If the filter -// is filled to maxFilterCapacity, it will force purge a single entry. +// is filled to maxFilterCapacity, it will force purge a single entry. This +// method is NOT threadsafe. func (f *replayFilter) compactFilter(now int64) { e := f.fifo.Front() for e != nil { @@ -116,8 +117,7 @@ func (f *replayFilter) compactFilter(now int64) { // a lot. This will eventually self-correct, but "eventually" // could be a long time. As much as this sucks, jettison the // entire filter. - f.filter = make(map[uint64]*filterEntry) - f.fifo = list.New() + f.reset() return } if deltaT < 3600*2 { @@ -135,4 +135,10 @@ func (f *replayFilter) compactFilter(now int64) { } } +// reset purges the entire filter. This methoid is NOT threadsafe. +func (f *replayFilter) reset() { + f.filter = make(map[uint64]*filterEntry) + f.fifo = list.New() +} + /* vim :set ts=4 sw=4 sts=4 noet : */ -- cgit v1.2.3