Add EventIPBlocklisted

This commit is contained in:
9seconds
2021-03-17 21:24:24 +03:00
parent 23519913f2
commit 2408f1530f
15 changed files with 128 additions and 2 deletions
+10
View File
@@ -52,6 +52,16 @@ func (p *Proxy) Serve(listener net.Listener) error {
return fmt.Errorf("cannot accept a new connection: %w", err)
}
if addr := conn.RemoteAddr().(*net.TCPAddr).IP; p.ipBlocklist.Contains(addr) {
conn.Close()
p.eventStream.Send(p.ctx, EventIPBlocklisted{
CreatedAt: time.Now(),
RemoteIP: addr,
})
continue
}
err = p.workerPool.Invoke(conn)
switch {