mirror of
https://github.com/netbirdio/netbird.git
synced 2025-04-26 04:19:47 +02:00
Add logging option for wg device (#2271)
This commit is contained in:
parent
d5ba2ef6ec
commit
bc09348f5a
@ -64,7 +64,7 @@ func (t *wgTunDevice) Create(routes []string, dns string, searchDomains []string
|
|||||||
t.wrapper = newDeviceWrapper(tunDevice)
|
t.wrapper = newDeviceWrapper(tunDevice)
|
||||||
|
|
||||||
log.Debugf("attaching to interface %v", name)
|
log.Debugf("attaching to interface %v", name)
|
||||||
t.device = device.NewDevice(t.wrapper, t.iceBind, device.NewLogger(device.LogLevelSilent, "[wiretrustee] "))
|
t.device = device.NewDevice(t.wrapper, t.iceBind, device.NewLogger(wgLogLevel(), "[wiretrustee] "))
|
||||||
// without this property mobile devices can discover remote endpoints if the configured one was wrong.
|
// without this property mobile devices can discover remote endpoints if the configured one was wrong.
|
||||||
// this helps with support for the older NetBird clients that had a hardcoded direct mode
|
// this helps with support for the older NetBird clients that had a hardcoded direct mode
|
||||||
// t.device.DisableSomeRoamingForBrokenMobileSemantics()
|
// t.device.DisableSomeRoamingForBrokenMobileSemantics()
|
||||||
|
@ -49,7 +49,7 @@ func (t *tunDevice) Create() (wgConfigurer, error) {
|
|||||||
t.device = device.NewDevice(
|
t.device = device.NewDevice(
|
||||||
t.wrapper,
|
t.wrapper,
|
||||||
t.iceBind,
|
t.iceBind,
|
||||||
device.NewLogger(device.LogLevelSilent, "[netbird] "),
|
device.NewLogger(wgLogLevel(), "[netbird] "),
|
||||||
)
|
)
|
||||||
|
|
||||||
err = t.assignAddr()
|
err = t.assignAddr()
|
||||||
|
@ -64,7 +64,7 @@ func (t *tunDevice) Create() (wgConfigurer, error) {
|
|||||||
|
|
||||||
t.wrapper = newDeviceWrapper(tunDevice)
|
t.wrapper = newDeviceWrapper(tunDevice)
|
||||||
log.Debug("Attaching to interface")
|
log.Debug("Attaching to interface")
|
||||||
t.device = device.NewDevice(t.wrapper, t.iceBind, device.NewLogger(device.LogLevelSilent, "[wiretrustee] "))
|
t.device = device.NewDevice(t.wrapper, t.iceBind, device.NewLogger(wgLogLevel(), "[wiretrustee] "))
|
||||||
// without this property mobile devices can discover remote endpoints if the configured one was wrong.
|
// without this property mobile devices can discover remote endpoints if the configured one was wrong.
|
||||||
// this helps with support for the older NetBird clients that had a hardcoded direct mode
|
// this helps with support for the older NetBird clients that had a hardcoded direct mode
|
||||||
// t.device.DisableSomeRoamingForBrokenMobileSemantics()
|
// t.device.DisableSomeRoamingForBrokenMobileSemantics()
|
||||||
|
@ -54,7 +54,7 @@ func (t *tunNetstackDevice) Create() (wgConfigurer, error) {
|
|||||||
t.device = device.NewDevice(
|
t.device = device.NewDevice(
|
||||||
t.wrapper,
|
t.wrapper,
|
||||||
t.iceBind,
|
t.iceBind,
|
||||||
device.NewLogger(device.LogLevelSilent, "[netbird] "),
|
device.NewLogger(wgLogLevel(), "[netbird] "),
|
||||||
)
|
)
|
||||||
|
|
||||||
t.configurer = newWGUSPConfigurer(t.device, t.name)
|
t.configurer = newWGUSPConfigurer(t.device, t.name)
|
||||||
|
@ -57,7 +57,7 @@ func (t *tunUSPDevice) Create() (wgConfigurer, error) {
|
|||||||
t.device = device.NewDevice(
|
t.device = device.NewDevice(
|
||||||
t.wrapper,
|
t.wrapper,
|
||||||
t.iceBind,
|
t.iceBind,
|
||||||
device.NewLogger(device.LogLevelSilent, "[netbird] "),
|
device.NewLogger(wgLogLevel(), "[netbird] "),
|
||||||
)
|
)
|
||||||
|
|
||||||
err = t.assignAddr()
|
err = t.assignAddr()
|
||||||
|
@ -41,6 +41,7 @@ func newTunDevice(name string, address WGAddress, port int, key string, mtu int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *tunDevice) Create() (wgConfigurer, error) {
|
func (t *tunDevice) Create() (wgConfigurer, error) {
|
||||||
|
log.Info("create tun interface")
|
||||||
tunDevice, err := tun.CreateTUN(t.name, t.mtu)
|
tunDevice, err := tun.CreateTUN(t.name, t.mtu)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -52,7 +53,7 @@ func (t *tunDevice) Create() (wgConfigurer, error) {
|
|||||||
t.device = device.NewDevice(
|
t.device = device.NewDevice(
|
||||||
t.wrapper,
|
t.wrapper,
|
||||||
t.iceBind,
|
t.iceBind,
|
||||||
device.NewLogger(device.LogLevelSilent, "[netbird] "),
|
device.NewLogger(wgLogLevel(), "[netbird] "),
|
||||||
)
|
)
|
||||||
|
|
||||||
luid := winipcfg.LUID(t.nativeTunDevice.LUID())
|
luid := winipcfg.LUID(t.nativeTunDevice.LUID())
|
||||||
|
15
iface/wg_log.go
Normal file
15
iface/wg_log.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package iface
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"golang.zx2c4.com/wireguard/device"
|
||||||
|
)
|
||||||
|
|
||||||
|
func wgLogLevel() int {
|
||||||
|
if os.Getenv("NB_WG_DEBUG") == "true" {
|
||||||
|
return device.LogLevelVerbose
|
||||||
|
} else {
|
||||||
|
return device.LogLevelSilent
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user