WIP: improve responsiveness.
This commit is contained in:
10
peer/app.go
10
peer/app.go
@@ -78,8 +78,8 @@ func (a *App) Run() error {
|
|||||||
// while we were down).
|
// while we were down).
|
||||||
a.updateHosts()
|
a.updateHosts()
|
||||||
|
|
||||||
ticker := time.NewTicker(PingInterval)
|
stateTicker := time.NewTicker(time.Second) // TODO: Const.
|
||||||
defer ticker.Stop()
|
pingTicker := time.NewTicker(PingInterval)
|
||||||
|
|
||||||
sig := make(chan os.Signal, 1)
|
sig := make(chan os.Signal, 1)
|
||||||
signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)
|
signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)
|
||||||
@@ -97,10 +97,12 @@ func (a *App) Run() error {
|
|||||||
a.onPing(e)
|
a.onPing(e)
|
||||||
case e := <-a.multicastCh:
|
case e := <-a.multicastCh:
|
||||||
a.onMulticastDiscovery(e)
|
a.onMulticastDiscovery(e)
|
||||||
case <-ticker.C:
|
case <-stateTicker.C:
|
||||||
a.onTick()
|
a.onTick()
|
||||||
|
case <-pingTicker.C:
|
||||||
|
a.onPingTicker()
|
||||||
tickCount++
|
tickCount++
|
||||||
if tickCount%8 == 0 {
|
if tickCount == 0 {
|
||||||
a.logNetworkState()
|
a.logNetworkState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
peer/on_pingticker.go
Normal file
15
peer/on_pingticker.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package peer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
"vppn/peer/control"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a *App) onPingTicker() {
|
||||||
|
now := time.Now().UnixNano()
|
||||||
|
for _, p := range a.peersByIP {
|
||||||
|
if p.Role == control.Client {
|
||||||
|
a.sendPing(p, now)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"net/netip"
|
"net/netip"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"vppn/peer/control"
|
|
||||||
"vppn/peer/wginterface"
|
"vppn/peer/wginterface"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,11 +29,6 @@ func (a *App) onTick() {
|
|||||||
p.EndpointWG = ep
|
p.EndpointWG = ep
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send pings to peers where we're the client.
|
|
||||||
if p.Role == control.Client {
|
|
||||||
a.sendPing(p, now)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch p.State {
|
switch p.State {
|
||||||
case StateRelayed:
|
case StateRelayed:
|
||||||
// If we have an ep to probe, add it.
|
// If we have an ep to probe, add it.
|
||||||
|
|||||||
Reference in New Issue
Block a user