shadowsocks / go-shadowsocks2

Modern Shadowsocks in Go
Apache License 2.0
4.45k stars 1.39k forks source link

Implement reuse detection for cipher #165

Closed oif closed 4 years ago

oif commented 4 years ago

Use bloom filter to withstand reuse 'attack'.

Same implementation as https://github.com/shadowsocks/shadowsocks-libev/blob/v3.3.4/src/ppbloom.c

oif commented 4 years ago

@riobard re-implement saltfilter and support change filter entries and FPS via ldflags(but saltfilter slot count fixed). And wait https://github.com/riobard/go-bloom/pull/1 merged to modify go.mod

oif commented 4 years ago

pardon me, I should post the general purpose of this PR.

  1. Implements a shared Bloom filter in saltfilter package and expose necessary function(Check and Test);
  2. Ciphers use this shared filter directly without initialize it manually or manage it alone.
riobard commented 4 years ago

Please make salfilter an internal package. I don't want to export any of its members to avoid outside use.

oif commented 4 years ago

@riobard How about create a github.com/shadowsocks/go-shadowsocks2/internal package and put filter inside?

riobard commented 4 years ago

I guess that's the way to do it.

oif commented 4 years ago

and also suppose public errors like var ErrShortPacket = errors.New("short packet") should define in one place(maybe internal or errors)

riobard commented 4 years ago

What do you mean? It's already exported.

oif commented 4 years ago

errors declared both in aead and steam package, it’s not necessary and hard to handle outside as well

riobard commented 4 years ago

We will remove shadowstream package soon (I've already removed it from my fork), so there's no need to worry about that.

oif commented 4 years ago

@riobard OK, then just keep those declaration

riobard commented 4 years ago

We should add the necessary documentation.

oif commented 4 years ago

@riobard yep, I'll create a new PR about this soon.