Compare commits
3 commits
6f355fe441
...
55f7ecae6b
Author | SHA1 | Date | |
---|---|---|---|
55f7ecae6b | |||
7820d2acf0 | |||
b0b6c702da |
1 changed files with 4 additions and 2 deletions
|
@ -16,10 +16,12 @@ func RemoveStaleClients() {
|
|||
for range ticker.C {
|
||||
mu.Lock()
|
||||
for _, client := range Clients {
|
||||
if !sendPing(client) || isStale(client) {
|
||||
ping := sendPing(client)
|
||||
stale := isStale(client)
|
||||
if !ping || stale {
|
||||
client.Conn.Close()
|
||||
delete(Clients, client.Conn.LocalAddr())
|
||||
helper.Logger.Info("Removed stale client", "host", client.RealIP)
|
||||
helper.Logger.Info("Removed stale client", "host", client.RealIP, "lastPong", client.LastPong.Format("RFC3339"))
|
||||
}
|
||||
}
|
||||
mu.Unlock()
|
||||
|
|
Loading…
Reference in a new issue