Keep track of errors and delete beyond error count > 3

This commit is contained in:
Asim Aslam
2019-09-25 12:14:09 +01:00
parent be5799b09f
commit 6c2b9d7636
2 changed files with 53 additions and 0 deletions

View File

@@ -200,6 +200,34 @@ func (t *tun) monitor() {
case <-t.closed:
return
case <-reconnect.C:
t.RLock()
var delLinks []string
// check the link status and purge dead links
for node, link := range t.links {
// check link status
switch link.Status() {
case "closed":
delLinks = append(delLinks, node)
case "error":
delLinks = append(delLinks, node)
}
}
t.RUnlock()
// delete the dead links
if len(delLinks) > 0 {
t.Lock()
for _, node := range delLinks {
link := t.links[node]
link.Close()
delete(t.links, node)
}
t.Unlock()
}
// check current link status
var connect []string
// build list of unknown nodes to connect to