mirror of
https://github.com/netbirdio/netbird.git
synced 2025-03-03 09:21:12 +01:00
code cleaning
This commit is contained in:
parent
ca9ea29255
commit
6a279c698c
@ -3,7 +3,7 @@ package dns
|
|||||||
type androidHostManager struct {
|
type androidHostManager struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHostManager(wgInterface WGIface, dnsManager IosDnsManager) (hostManager, error) {
|
func newHostManager() (hostManager, error) {
|
||||||
return &androidHostManager{}, nil
|
return &androidHostManager{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ type systemConfigurator struct {
|
|||||||
createdKeys map[string]struct{}
|
createdKeys map[string]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHostManager(_ WGIface, dnsManager IosDnsManager) (hostManager, error) {
|
func newHostManager() (hostManager, error) {
|
||||||
return &systemConfigurator{
|
return &systemConfigurator{
|
||||||
createdKeys: make(map[string]struct{}),
|
createdKeys: make(map[string]struct{}),
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -10,7 +10,7 @@ type iosHostManager struct {
|
|||||||
config hostDNSConfig
|
config hostDNSConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHostManager(wgInterface WGIface, dnsManager IosDnsManager) (hostManager, error) {
|
func newHostManager(dnsManager IosDnsManager) (hostManager, error) {
|
||||||
return &iosHostManager{
|
return &iosHostManager{
|
||||||
dnsManager: dnsManager,
|
dnsManager: dnsManager,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -25,7 +25,7 @@ const (
|
|||||||
|
|
||||||
type osManagerType int
|
type osManagerType int
|
||||||
|
|
||||||
func newHostManager(wgInterface WGIface, dnsManager IosDnsManager) (hostManager, error) {
|
func newHostManager(wgInterface WGIface) (hostManager, error) {
|
||||||
osManager, err := getOSDNSManagerType()
|
osManager, err := getOSDNSManagerType()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -29,7 +29,7 @@ type registryConfigurator struct {
|
|||||||
routingAll bool
|
routingAll bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHostManager(wgInterface WGIface, dnsManager IosDnsManager) (hostManager, error) {
|
func newHostManager(wgInterface WGIface) (hostManager, error) {
|
||||||
guid, err := wgInterface.GetInterfaceGUIDString()
|
guid, err := wgInterface.GetInterfaceGUIDString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"runtime"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@ -127,7 +126,7 @@ func newDefaultServer(ctx context.Context, wgInterface WGIface, dnsService servi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize instantiate host manager and the dns service
|
// Initialize instantiate host manager and the dns service
|
||||||
func (s *DefaultServer) Initialize(manager IosDnsManager) (err error) {
|
func (s *DefaultServer) Initialize() (err error) {
|
||||||
s.mux.Lock()
|
s.mux.Lock()
|
||||||
defer s.mux.Unlock()
|
defer s.mux.Unlock()
|
||||||
|
|
||||||
@ -135,19 +134,8 @@ func (s *DefaultServer) Initialize(manager IosDnsManager) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.permanent {
|
s.hostManager, err = s.initialize()
|
||||||
err = s.service.Listen()
|
return err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if runtime.GOOS == "ios" {
|
|
||||||
s.hostManager, err = newHostManager(nil, manager)
|
|
||||||
} else {
|
|
||||||
s.hostManager, err = newHostManager(s.wgInterface, nil)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DnsIP returns the DNS resolver server IP address
|
// DnsIP returns the DNS resolver server IP address
|
||||||
|
10
client/internal/dns/server_android.go
Normal file
10
client/internal/dns/server_android.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
func (s *DefaultServer) initialize() (manager hostManager, err error) {
|
||||||
|
err = s.service.Listen()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return newHostManager()
|
||||||
|
}
|
5
client/internal/dns/server_darwin.go
Normal file
5
client/internal/dns/server_darwin.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
func (s *DefaultServer) initialize() (manager hostManager, err error) {
|
||||||
|
return newHostManager()
|
||||||
|
}
|
6
client/internal/dns/server_ios.go
Normal file
6
client/internal/dns/server_ios.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
func (s *DefaultServer) initialize() (manager hostManager, err error) {
|
||||||
|
// todo add ioDnsManager to constuctor
|
||||||
|
return newHostManager(m.ioDnsManager)
|
||||||
|
}
|
5
client/internal/dns/server_linux.go
Normal file
5
client/internal/dns/server_linux.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
func (s *DefaultServer) initialize() (manager hostManager, err error) {
|
||||||
|
return newHostManager(s.wgInterface)
|
||||||
|
}
|
5
client/internal/dns/server_windows.go
Normal file
5
client/internal/dns/server_windows.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package dns
|
||||||
|
|
||||||
|
func (s *DefaultServer) initialize() (manager hostManager, err error) {
|
||||||
|
return newHostManager(s.wgInterface)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user