2024-05-07 18:50:34 +02:00
|
|
|
package networkmonitor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-05-17 09:43:18 +02:00
|
|
|
"errors"
|
|
|
|
"sync"
|
2024-05-07 18:50:34 +02:00
|
|
|
)
|
|
|
|
|
2024-05-17 09:43:18 +02:00
|
|
|
var ErrStopped = errors.New("monitor has been stopped")
|
|
|
|
|
|
|
|
// NetworkMonitor watches for changes in network configuration.
|
|
|
|
type NetworkMonitor struct {
|
2024-05-07 18:50:34 +02:00
|
|
|
cancel context.CancelFunc
|
2024-05-17 09:43:18 +02:00
|
|
|
wg sync.WaitGroup
|
|
|
|
mu sync.Mutex
|
2024-05-07 18:50:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// New creates a new network monitor.
|
2024-05-17 09:43:18 +02:00
|
|
|
func New() *NetworkMonitor {
|
|
|
|
return &NetworkMonitor{}
|
2024-05-07 18:50:34 +02:00
|
|
|
}
|