Ported remaining netns.sh

- Ported remaining netns.sh tests
- Begin work on generic implementation of bind interface
This commit is contained in:
Mathias Hall-Andersen
2017-11-17 17:25:45 +01:00
parent e1227d3af4
commit fa399a91d5
13 changed files with 194 additions and 28 deletions

View File

@@ -8,8 +8,9 @@ import (
)
type Device struct {
log *Logger // collection of loggers for levels
idCounter uint // for assigning debug ids to peers
closed AtomicBool // device is closed? (acting as guard)
log *Logger // collection of loggers for levels
idCounter uint // for assigning debug ids to peers
fwMark uint32
tun struct {
device TUNDevice
@@ -203,6 +204,9 @@ func (device *Device) RemoveAllPeers() {
}
func (device *Device) Close() {
if device.closed.Swap(true) {
return
}
device.log.Info.Println("Closing device")
device.RemoveAllPeers()
close(device.signal.stop)