diff options
Diffstat (limited to 'device/tun.go')
-rw-r--r-- | device/tun.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/device/tun.go b/device/tun.go index 3816f9b..97f1276 100644 --- a/device/tun.go +++ b/device/tun.go @@ -15,41 +15,37 @@ const DefaultMTU = 1420 func (device *Device) RoutineTUNEventReader() { setUp := false - logDebug := device.log.Debug - logInfo := device.log.Info - logError := device.log.Error - - logDebug.Println("Routine: event worker - started") + device.debugf("Routine: event worker - started") for event := range device.tun.device.Events() { if event&tun.EventMTUUpdate != 0 { mtu, err := device.tun.device.MTU() old := atomic.LoadInt32(&device.tun.mtu) if err != nil { - logError.Println("Failed to load updated MTU of device:", err) + device.errorf("Failed to load updated MTU of device: %v", err) } else if int(old) != mtu { if mtu+MessageTransportSize > MaxMessageSize { - logInfo.Println("MTU updated:", mtu, "(too large)") + device.infof("MTU updated: %v (too large)", mtu) } else { - logInfo.Println("MTU updated:", mtu) + device.infof("MTU updated: %v", mtu) } atomic.StoreInt32(&device.tun.mtu, int32(mtu)) } } if event&tun.EventUp != 0 && !setUp { - logInfo.Println("Interface set up") + device.infof("Interface set up") setUp = true device.Up() } if event&tun.EventDown != 0 && setUp { - logInfo.Println("Interface set down") + device.infof("Interface set down") setUp = false device.Down() } } - logDebug.Println("Routine: event worker - stopped") + device.debugf("Routine: event worker - stopped") device.state.stopping.Done() } |