diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-02-11 18:55:30 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-02-11 18:55:30 +0100 |
commit | 73cb1a115569455566e7091ce8d98f31e4fdfddf (patch) | |
tree | 0bc62575681965dbd14a0dc64df2b9af252135f0 /tun.go | |
parent | b461343171726d99df20bfc4b4741f0fad0c95e0 (diff) |
Reverted event changes
This feature was not needed for Android, upon further inspection.
Diffstat (limited to 'tun.go')
-rw-r--r-- | tun.go | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -1,13 +1,14 @@ package main import ( - "git.zx2c4.com/wireguard-go/internal/events" "os" "sync/atomic" ) const DefaultMTU = 1420 +type TUNEvent int + const ( TUNEventUp = 1 << iota TUNEventDown @@ -20,7 +21,7 @@ type TUNDevice interface { Write([]byte, int) (int, error) // writes a packet to the device (without any additional headers) MTU() (int, error) // returns the MTU of the device Name() string // returns the current name - Events() chan events.Event // returns a constant channel of events related to the device + Events() chan TUNEvent // returns a constant channel of events related to the device Close() error // stops the device and closes the event channel } @@ -29,8 +30,7 @@ func (device *Device) RoutineTUNEventReader() { logError := device.log.Error for event := range device.tun.device.Events() { - - if event.Contains(TUNEventMTUUpdate) { + if event&TUNEventMTUUpdate != 0 { mtu, err := device.tun.device.MTU() old := atomic.LoadInt32(&device.tun.mtu) if err != nil { @@ -45,16 +45,14 @@ func (device *Device) RoutineTUNEventReader() { } } - if event.Contains(TUNEventUp) && !device.isUp.Get() { + if event&TUNEventUp != 0 && !device.isUp.Get() { logInfo.Println("Interface set up") device.Up() } - if event.Contains(TUNEventDown) && device.isUp.Get() { + if event&TUNEventDown != 0 && device.isUp.Get() { logInfo.Println("Interface set down") device.Down() } - - event.Processed() } } |