David Why Use Two When One Will Do Presotto | f6813ec | 2014-07-11 16:12:54 -0700 | [diff] [blame] | 1 | // package netconfig implements a network configuration watcher. |
| 2 | // NOTE(p): This is also where we should put any code that changes |
| 3 | // network configuration. |
| 4 | |
| 5 | package netconfig |
| 6 | |
David Why Use Two When One Will Do Presotto | 3e529b9 | 2014-09-29 10:24:01 -0700 | [diff] [blame] | 7 | import ( |
| 8 | "net" |
| 9 | ) |
| 10 | |
David Why Use Two When One Will Do Presotto | f6813ec | 2014-07-11 16:12:54 -0700 | [diff] [blame] | 11 | // NetConfigWatcher sends on channel whenever an interface or interface address |
| 12 | // is added or deleted. |
| 13 | type NetConfigWatcher interface { |
| 14 | // Stop watching. |
| 15 | Stop() |
| 16 | |
| 17 | // A channel that returns an item whenever the network addresses or |
| 18 | // interfaces have changed. It is up to the caller to reread the |
| 19 | // network configuration in such cases. |
| 20 | Channel() chan struct{} |
| 21 | } |
David Why Use Two When One Will Do Presotto | 3e529b9 | 2014-09-29 10:24:01 -0700 | [diff] [blame] | 22 | |
| 23 | // IPRoute represents a route in the kernel's routing table. |
| 24 | // Any route with a nil Gateway is a directly connected network. |
| 25 | type IPRoute struct { |
| 26 | Net net.IPNet |
| 27 | Gateway net.IP |
| 28 | PreferredSource net.IP |
| 29 | IfcIndex int |
| 30 | } |