mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-02 04:53:51 +01:00
33 lines
626 B
Go
33 lines
626 B
Go
package systemops
|
|
|
|
import (
|
|
"net/netip"
|
|
"sync"
|
|
|
|
"github.com/netbirdio/netbird/client/internal/routemanager/refcounter"
|
|
)
|
|
|
|
type ShutdownState struct {
|
|
Counter *ExclusionCounter `json:"counter,omitempty"`
|
|
mu sync.RWMutex
|
|
}
|
|
|
|
func (s *ShutdownState) Name() string {
|
|
return "route_state"
|
|
}
|
|
|
|
func (s *ShutdownState) Cleanup() error {
|
|
s.mu.RLock()
|
|
defer s.mu.RUnlock()
|
|
|
|
if s.Counter == nil {
|
|
return nil
|
|
}
|
|
|
|
sysops := NewSysOps(nil, nil)
|
|
sysops.refCounter = refcounter.New[netip.Prefix, struct{}, Nexthop](nil, sysops.removeFromRouteTable)
|
|
sysops.refCounter.LoadData(s.Counter)
|
|
|
|
return sysops.refCounter.Flush()
|
|
}
|