mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-25 08:43:08 +01:00
CheckAnyShouldUpdate
This commit is contained in:
parent
157c218d30
commit
fd80661060
@ -753,9 +753,11 @@ func (device *Device) RoutineRecalculateNhTable() {
|
||||
}
|
||||
if device.IsSuperNode {
|
||||
for {
|
||||
changed := device.graph.RecalculateNhTable(true)
|
||||
if changed {
|
||||
device.Event_server_NhTable_changed <- struct{}{}
|
||||
if device.graph.CheckAnyShouldUpdate() {
|
||||
changed := device.graph.RecalculateNhTable(true)
|
||||
if changed {
|
||||
device.Event_server_NhTable_changed <- struct{}{}
|
||||
}
|
||||
}
|
||||
time.Sleep(device.graph.TimeoutCheckInterval)
|
||||
}
|
||||
@ -765,7 +767,9 @@ func (device *Device) RoutineRecalculateNhTable() {
|
||||
}
|
||||
for {
|
||||
if time.Now().After(device.graph.NhTableExpire) {
|
||||
device.graph.RecalculateNhTable(false)
|
||||
if device.graph.CheckAnyShouldUpdate() {
|
||||
device.graph.RecalculateNhTable(false)
|
||||
}
|
||||
}
|
||||
time.Sleep(device.graph.TimeoutCheckInterval)
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -44,6 +44,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -44,6 +44,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -44,6 +44,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -44,6 +44,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -44,6 +44,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -428,6 +428,7 @@ Return value:
|
||||
1. jittertolerancemultiplier: the same is the jitter tolerance, but high ping allows more errors
|
||||
https://www.desmos.com/calculator/raoti16r5n
|
||||
1. nodereporttimeout: The timeout of the received `Pong` packet. Change back to Infinity after timeout.
|
||||
1. timeoutcheckinterval: The interval to check if there any `Pong` packet timeouted, and recalculate the NhTable
|
||||
1. nexthoptable: only works in `staticmode==true`, set nexthoptable manually
|
||||
1. edgetemplate: for `addpeer` API. Refer to this configuration file and show a sample configuration file of the edge to the user
|
||||
1. usepskforinteredge: Whether to enable pre-share key communication between edges. If enabled, supernode will generate PSKs for edges automatically
|
||||
|
@ -431,6 +431,7 @@ curl "http://127.0.0.1:3000/api/peer/del?privkey=IJtpnkm9ytbuCukx4VBMENJKuLngo9K
|
||||
1. jittertolerancemultiplier: 一樣是抖動容許誤差,但是高ping的話允許更多誤差
|
||||
https://www.desmos.com/calculator/raoti16r5n
|
||||
1. nodereporttimeout: 收到的`Pong`封包的有效期限。太久沒收到就變回Infinity
|
||||
1. timeoutcheckinterval: 固定間格檢查,有沒有人的Pong封包超過有效期限,要重算轉發表
|
||||
1. nexthoptable: 僅在`staticmode==true` 有效,手動設定的nexthoptable
|
||||
1. edgetemplate: 給`addpeer`API用的。參考這個設定檔,顯示一個範例設定檔給edge
|
||||
1. usepskforinteredge: 是否啟用edge間pre shares key通信。若啟用則幫edge們自動生成PSK
|
||||
|
@ -45,6 +45,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
@ -45,6 +45,7 @@ dynamicroute:
|
||||
jittertolerance: 20
|
||||
jittertolerancemultiplier: 1.1
|
||||
nodereporttimeout: 40
|
||||
timeoutcheckinterval: 5
|
||||
recalculatecooldown: 5
|
||||
ntpconfig:
|
||||
usentp: true
|
||||
|
13
path/path.go
13
path/path.go
@ -110,6 +110,19 @@ func (g *IG) ShouldUpdate(u config.Vertex, v config.Vertex, newval float64) bool
|
||||
}
|
||||
}
|
||||
|
||||
func (g *IG) CheckAnyShouldUpdate() bool {
|
||||
vert := g.Vertices()
|
||||
for u, _ := range vert {
|
||||
for v, _ := range vert {
|
||||
newVal := g.Weight(u, v)
|
||||
if g.ShouldUpdate(u, v, newVal) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *IG) RecalculateNhTable(checkchange bool) (changed bool) {
|
||||
if g.StaticMode {
|
||||
if bytes.Equal(g.NhTableHash[:], make([]byte, 32)) {
|
||||
|
Loading…
Reference in New Issue
Block a user