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).
|
||||
a.updateHosts()
|
||||
|
||||
ticker := time.NewTicker(PingInterval)
|
||||
defer ticker.Stop()
|
||||
stateTicker := time.NewTicker(time.Second) // TODO: Const.
|
||||
pingTicker := time.NewTicker(PingInterval)
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)
|
||||
@@ -97,10 +97,12 @@ func (a *App) Run() error {
|
||||
a.onPing(e)
|
||||
case e := <-a.multicastCh:
|
||||
a.onMulticastDiscovery(e)
|
||||
case <-ticker.C:
|
||||
case <-stateTicker.C:
|
||||
a.onTick()
|
||||
case <-pingTicker.C:
|
||||
a.onPingTicker()
|
||||
tickCount++
|
||||
if tickCount%8 == 0 {
|
||||
if tickCount == 0 {
|
||||
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"
|
||||
"time"
|
||||
|
||||
"vppn/peer/control"
|
||||
"vppn/peer/wginterface"
|
||||
)
|
||||
|
||||
@@ -30,11 +29,6 @@ func (a *App) onTick() {
|
||||
p.EndpointWG = ep
|
||||
}
|
||||
|
||||
// Send pings to peers where we're the client.
|
||||
if p.Role == control.Client {
|
||||
a.sendPing(p, now)
|
||||
}
|
||||
|
||||
switch p.State {
|
||||
case StateRelayed:
|
||||
// If we have an ep to probe, add it.
|
||||
|
||||
Reference in New Issue
Block a user