mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
net/netmon, add: add netmon.State type alias of interfaces.State
... in prep for merging the net/interfaces package into net/netmon. This is a no-op change that updates a bunch of the API signatures ahead of a future change to actually move things (and remove the type alias) Updates tailscale/corp#10910 Updates tailscale/corp#18960 Updates #7967 Updates #3299 Change-Id: I477613388f09389214db0d77ccf24a65bff2199c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
45f0721530
commit
6b95219e3a
@@ -64,7 +64,7 @@ type Monitor struct {
|
||||
mu sync.Mutex // guards all following fields
|
||||
cbs set.HandleSet[ChangeFunc]
|
||||
ruleDelCB set.HandleSet[RuleDeleteCallback]
|
||||
ifState *interfaces.State
|
||||
ifState *State
|
||||
gwValid bool // whether gw and gwSelfIP are valid
|
||||
gw netip.Addr // our gateway's IP
|
||||
gwSelfIP netip.Addr // our own IP address (that corresponds to gw)
|
||||
@@ -88,12 +88,12 @@ type ChangeDelta struct {
|
||||
// Old is the old interface state, if known.
|
||||
// It's nil if the old state is unknown.
|
||||
// Do not mutate it.
|
||||
Old *interfaces.State
|
||||
Old *State
|
||||
|
||||
// New is the new network state.
|
||||
// It is always non-nil.
|
||||
// Do not mutate it.
|
||||
New *interfaces.State
|
||||
New *State
|
||||
|
||||
// Major is our legacy boolean of whether the network changed in some major
|
||||
// way.
|
||||
@@ -155,13 +155,13 @@ func NewStatic() *Monitor {
|
||||
// interfaces.
|
||||
//
|
||||
// The returned value is owned by Mon; it must not be modified.
|
||||
func (m *Monitor) InterfaceState() *interfaces.State {
|
||||
func (m *Monitor) InterfaceState() *State {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
return m.ifState
|
||||
}
|
||||
|
||||
func (m *Monitor) interfaceStateUncached() (*interfaces.State, error) {
|
||||
func (m *Monitor) interfaceStateUncached() (*State, error) {
|
||||
return interfaces.GetState()
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ var (
|
||||
// up callers and updates the monitor's state if so.
|
||||
//
|
||||
// If forceCallbacks is true, they're always notified.
|
||||
func (m *Monitor) handlePotentialChange(newState *interfaces.State, forceCallbacks bool) {
|
||||
func (m *Monitor) handlePotentialChange(newState *State, forceCallbacks bool) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
oldState := m.ifState
|
||||
@@ -476,7 +476,7 @@ func (m *Monitor) handlePotentialChange(newState *interfaces.State, forceCallbac
|
||||
// a bunch of connections and rebinding.
|
||||
//
|
||||
// TODO(bradiftz): tigten this definition.
|
||||
func (m *Monitor) IsMajorChangeFrom(s1, s2 *interfaces.State) bool {
|
||||
func (m *Monitor) IsMajorChangeFrom(s1, s2 *State) bool {
|
||||
if s1 == nil && s2 == nil {
|
||||
return false
|
||||
}
|
||||
|
8
net/netmon/state.go
Normal file
8
net/netmon/state.go
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package netmon
|
||||
|
||||
import "tailscale.com/net/interfaces"
|
||||
|
||||
type State = interfaces.State // temporary (2024-04-27) alias during multi-step removal of net/interfaces
|
Reference in New Issue
Block a user