mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-21 23:03:08 +01:00
FastTry
This commit is contained in:
parent
056f7173a0
commit
91d8e92b39
@ -107,10 +107,11 @@ func (et *endpoint_trylist) Delete(url string) {
|
||||
delete(et.trymap_p2p, url)
|
||||
}
|
||||
|
||||
func (et *endpoint_trylist) GetNextTry() string {
|
||||
func (et *endpoint_trylist) GetNextTry() (bool, string) {
|
||||
et.RLock()
|
||||
defer et.RUnlock()
|
||||
var smallest *endpoint_tryitem
|
||||
FastTry := true
|
||||
for _, v := range et.trymap_super {
|
||||
if smallest == nil || smallest.lastTry.After(v.lastTry) {
|
||||
smallest = v
|
||||
@ -128,13 +129,16 @@ func (et *endpoint_trylist) GetNextTry() string {
|
||||
}
|
||||
}
|
||||
if smallest == nil {
|
||||
return ""
|
||||
return false, ""
|
||||
}
|
||||
smallest.lastTry = time.Now()
|
||||
if smallest.firstTry.After(time.Time{}) {
|
||||
smallest.firstTry = time.Now()
|
||||
}
|
||||
return smallest.URL
|
||||
if smallest.firstTry.Add(et.timeout).Before(time.Now()) {
|
||||
FastTry = false
|
||||
}
|
||||
return FastTry, smallest.URL
|
||||
}
|
||||
|
||||
type Peer struct {
|
||||
|
@ -647,7 +647,7 @@ func (device *Device) RoutineSetEndpoint() {
|
||||
//Peer alives
|
||||
continue
|
||||
} else {
|
||||
connurl := thepeer.endpoint_trylist.GetNextTry()
|
||||
FastTry, connurl := thepeer.endpoint_trylist.GetNextTry()
|
||||
if connurl == "" {
|
||||
continue
|
||||
}
|
||||
@ -657,8 +657,10 @@ func (device *Device) RoutineSetEndpoint() {
|
||||
thepeer.endpoint_trylist.Delete(connurl)
|
||||
continue
|
||||
}
|
||||
NextRun = true
|
||||
go device.SendPing(thepeer, int(device.DRoute.ConnNextTry+1), 1, 1)
|
||||
if FastTry {
|
||||
NextRun = true
|
||||
go device.SendPing(thepeer, int(device.DRoute.ConnNextTry+1), 1, 1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user