mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-25 12:12:12 +02:00
Remove unnecessary uapi open (#807)
Remove unnecessary uapi open from Android implementation
This commit is contained in:
parent
4616bc5258
commit
bb147c2a7c
@ -1,18 +1,15 @@
|
|||||||
package iface
|
package iface
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pion/transport/v2"
|
"github.com/pion/transport/v2"
|
||||||
|
|
||||||
"github.com/netbirdio/netbird/iface/bind"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"golang.zx2c4.com/wireguard/device"
|
"golang.zx2c4.com/wireguard/device"
|
||||||
"golang.zx2c4.com/wireguard/ipc"
|
|
||||||
"golang.zx2c4.com/wireguard/tun"
|
"golang.zx2c4.com/wireguard/tun"
|
||||||
|
|
||||||
|
"github.com/netbirdio/netbird/iface/bind"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tunDevice struct {
|
type tunDevice struct {
|
||||||
@ -24,7 +21,6 @@ type tunDevice struct {
|
|||||||
fd int
|
fd int
|
||||||
name string
|
name string
|
||||||
device *device.Device
|
device *device.Device
|
||||||
uapi net.Listener
|
|
||||||
iceBind *bind.ICEBind
|
iceBind *bind.ICEBind
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,32 +54,8 @@ func (t *tunDevice) Create() error {
|
|||||||
t.device = device.NewDevice(tunDevice, t.iceBind, device.NewLogger(device.LogLevelSilent, "[wiretrustee] "))
|
t.device = device.NewDevice(tunDevice, t.iceBind, device.NewLogger(device.LogLevelSilent, "[wiretrustee] "))
|
||||||
t.device.DisableSomeRoamingForBrokenMobileSemantics()
|
t.device.DisableSomeRoamingForBrokenMobileSemantics()
|
||||||
|
|
||||||
log.Debugf("create uapi")
|
|
||||||
tunSock, err := ipc.UAPIOpen(name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
t.uapi, err = ipc.UAPIListen(name, tunSock)
|
|
||||||
if err != nil {
|
|
||||||
tunSock.Close()
|
|
||||||
unix.Close(t.fd)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
uapiConn, err := t.uapi.Accept()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go t.device.IpcHandle(uapiConn)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
err = t.device.Up()
|
err = t.device.Up()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tunSock.Close()
|
|
||||||
t.device.Close()
|
t.device.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -109,10 +81,6 @@ func (t *tunDevice) UpdateAddr(addr WGAddress) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *tunDevice) Close() (err error) {
|
func (t *tunDevice) Close() (err error) {
|
||||||
if t.uapi != nil {
|
|
||||||
err = t.uapi.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
if t.device != nil {
|
if t.device != nil {
|
||||||
t.device.Close()
|
t.device.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user