Browse Source

add anti-brute force mechanism

pull/169/head
aler9 5 years ago
parent
commit
d83aa880cc
  1. 33
      internal/client/client.go

33
internal/client/client.go

@ -28,6 +28,7 @@ const ( @@ -28,6 +28,7 @@ const (
checkStreamInterval = 5 * time.Second
receiverReportInterval = 10 * time.Second
sessionID = "12345678"
pauseAfterAuthError = 2 * time.Second
)
type streamTrack struct {
@ -234,6 +235,14 @@ func (c *Client) run() { @@ -234,6 +235,14 @@ func (c *Client) run() {
return terr.Response, nil
case errAuthCritical:
// wait some seconds to stop brute force attacks
t := time.NewTimer(pauseAfterAuthError)
defer t.Stop()
select {
case <-t.C:
case <-c.terminate:
}
return terr.Response, errTerminated
default:
@ -317,6 +326,14 @@ func (c *Client) run() { @@ -317,6 +326,14 @@ func (c *Client) run() {
return terr.Response, nil
case errAuthCritical:
// wait some seconds to stop brute force attacks
t := time.NewTimer(pauseAfterAuthError)
defer t.Stop()
select {
case <-t.C:
case <-c.terminate:
}
return terr.Response, errTerminated
default:
@ -415,6 +432,14 @@ func (c *Client) run() { @@ -415,6 +432,14 @@ func (c *Client) run() {
return terr.Response, nil
case errAuthCritical:
// wait some seconds to stop brute force attacks
t := time.NewTimer(pauseAfterAuthError)
defer t.Stop()
select {
case <-t.C:
case <-c.terminate:
}
return terr.Response, errTerminated
default:
@ -473,6 +498,14 @@ func (c *Client) run() { @@ -473,6 +498,14 @@ func (c *Client) run() {
return terr.Response, nil
case errAuthCritical:
// wait some seconds to stop brute force attacks
t := time.NewTimer(pauseAfterAuthError)
defer t.Stop()
select {
case <-t.C:
case <-c.terminate:
}
return terr.Response, errTerminated
default:

Loading…
Cancel
Save