mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-03 07:36:39 +00:00
merge main
This commit is contained in:
@@ -282,7 +282,7 @@ func (a *xorMapped) closeWaiters() {
|
||||
// just exit
|
||||
break
|
||||
default:
|
||||
// notify tha twe have a new addr
|
||||
// notify that twe have a new addr
|
||||
close(a.waitAddrReceived)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestDeviceWrapperRead(t *testing.T) {
|
||||
|
||||
n, err := wrapped.Read(bufs, sizes, offset)
|
||||
if err != nil {
|
||||
t.Errorf("unexpeted error: %v", err)
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
return
|
||||
}
|
||||
if n != 1 {
|
||||
@@ -105,7 +105,7 @@ func TestDeviceWrapperRead(t *testing.T) {
|
||||
|
||||
n, err := wrapped.Write(bufs, 0)
|
||||
if err != nil {
|
||||
t.Errorf("unexpeted error: %v", err)
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
return
|
||||
}
|
||||
if n != 1 {
|
||||
@@ -154,7 +154,7 @@ func TestDeviceWrapperRead(t *testing.T) {
|
||||
|
||||
n, err := wrapped.Write(bufs, 0)
|
||||
if err != nil {
|
||||
t.Errorf("unexpeted error: %v", err)
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
return
|
||||
}
|
||||
if n != 0 {
|
||||
@@ -211,7 +211,7 @@ func TestDeviceWrapperRead(t *testing.T) {
|
||||
|
||||
n, err := wrapped.Read(bufs, sizes, offset)
|
||||
if err != nil {
|
||||
t.Errorf("unexpeted error: %v", err)
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
return
|
||||
}
|
||||
if n != 0 {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
|
||||
// keep darwin compability
|
||||
// keep darwin compatibility
|
||||
const (
|
||||
WgIntNumber = 2000
|
||||
)
|
||||
|
||||
@@ -110,7 +110,7 @@ func canCreateFakeWireGuardInterface() bool {
|
||||
// We willingly try to create a device with an invalid
|
||||
// MTU here as the validation of the MTU will be performed after
|
||||
// the validation of the link kind and hence allows us to check
|
||||
// for the existance of the wireguard module without actually
|
||||
// for the existence of the wireguard module without actually
|
||||
// creating a link.
|
||||
//
|
||||
// As a side-effect, this will also let the kernel lazy-load
|
||||
@@ -271,12 +271,12 @@ func moduleStatus(name string) (status, error) {
|
||||
func loadModuleWithDependencies(name, path string) error {
|
||||
deps, err := getModuleDependencies(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't load list of module %s dependecies", name)
|
||||
return fmt.Errorf("couldn't load list of module %s dependencies", name)
|
||||
}
|
||||
for _, dep := range deps {
|
||||
err = loadModule(dep.name, dep.path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't load dependecy module %s for %s", dep.name, name)
|
||||
return fmt.Errorf("couldn't load dependency module %s for %s", dep.name, name)
|
||||
}
|
||||
}
|
||||
return loadModule(name, path)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package iface
|
||||
|
||||
type MobileIFaceArguments struct {
|
||||
Routes []string
|
||||
Dns string
|
||||
Routes []string
|
||||
Dns string
|
||||
SearchDomains []string
|
||||
}
|
||||
|
||||
// NetInterface represents a generic network tunnel interface
|
||||
|
||||
@@ -2,6 +2,6 @@ package iface
|
||||
|
||||
// TunAdapter is an interface for create tun device from externel service
|
||||
type TunAdapter interface {
|
||||
ConfigureInterface(address string, mtu int, dns string, routes string) (int, error)
|
||||
ConfigureInterface(address string, mtu int, dns string, searchDomains string, routes string) (int, error)
|
||||
UpdateAddr(address string) error
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ func (t *tunDevice) Create(mIFaceArgs MobileIFaceArguments) error {
|
||||
log.Info("create tun interface")
|
||||
var err error
|
||||
routesString := t.routesToString(mIFaceArgs.Routes)
|
||||
t.fd, err = t.tunAdapter.ConfigureInterface(t.address.String(), t.mtu, mIFaceArgs.Dns, routesString)
|
||||
searchDomainsToString := t.searchDomainsToString(mIFaceArgs.SearchDomains)
|
||||
t.fd, err = t.tunAdapter.ConfigureInterface(t.address.String(), t.mtu, mIFaceArgs.Dns, searchDomainsToString, routesString)
|
||||
if err != nil {
|
||||
log.Errorf("failed to create Android interface: %s", err)
|
||||
return err
|
||||
@@ -97,3 +98,7 @@ func (t *tunDevice) Close() (err error) {
|
||||
func (t *tunDevice) routesToString(routes []string) string {
|
||||
return strings.Join(routes, ";")
|
||||
}
|
||||
|
||||
func (t *tunDevice) searchDomainsToString(searchDomains []string) string {
|
||||
return strings.Join(searchDomains, ";")
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (c *tunDevice) Create() error {
|
||||
func (c *tunDevice) assignAddr() error {
|
||||
cmd := exec.Command("ifconfig", c.name, "inet", c.address.IP.String(), c.address.IP.String())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Infof(`adding addreess command "%v" failed with output %s and error: `, cmd.String(), out)
|
||||
log.Infof(`adding address command "%v" failed with output %s and error: `, cmd.String(), out)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user