Add EventReplayAttack

This commit is contained in:
9seconds
2021-03-29 12:07:18 +03:00
parent bef14bd009
commit daa8b9c798
14 changed files with 114 additions and 3 deletions
+13
View File
@@ -99,3 +99,16 @@ func (e EventIPBlocklisted) StreamID() string {
func (e EventIPBlocklisted) Timestamp() time.Time {
return e.CreatedAt
}
type EventReplayAttack struct {
CreatedAt time.Time
ConnID string
}
func (e EventReplayAttack) StreamID() string {
return e.ConnID
}
func (e EventReplayAttack) Timestamp() time.Time {
return e.CreatedAt
}
+10
View File
@@ -87,6 +87,16 @@ func (suite *EventsTestSuite) TestEventIPBlocklisted() {
suite.WithinDuration(time.Now(), evt.Timestamp(), 10*time.Millisecond)
}
func (suite *EventsTestSuite) TestEventReplayAttack() {
evt := mtglib.EventReplayAttack{
CreatedAt: time.Now(),
ConnID: "CONNID",
}
suite.Equal("CONNID", evt.StreamID())
suite.WithinDuration(time.Now(), evt.Timestamp(), 10*time.Millisecond)
}
func TestEvents(t *testing.T) {
t.Parallel()
suite.Run(t, &EventsTestSuite{})
+4
View File
@@ -166,6 +166,10 @@ func (p *Proxy) doFakeTLSHandshake(ctx *streamContext) bool {
if p.antiReplayCache.SeenBefore(hello.SessionID) {
p.logger.Warning("replay attack has been detected!")
p.eventStream.Send(p.ctx, EventReplayAttack{
CreatedAt: time.Now(),
ConnID: ctx.connID,
})
p.doDomainFronting(ctx, rewind)
return false