Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dns client configuration #563

Merged
merged 51 commits into from
Nov 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
bc0e61b
configure darwin split domain resolution
mlsmaycon Nov 11, 2022
220e9eb
check if answer is empty
mlsmaycon Nov 12, 2022
25ae67b
pass wireguard interface to dnsserver
mlsmaycon Nov 13, 2022
3455098
add macos host manager
mlsmaycon Nov 13, 2022
aa815f8
add windows host manager
mlsmaycon Nov 14, 2022
b3a937e
Merge branch 'main' into feature/dns-client-configuration
mlsmaycon Nov 14, 2022
c95e591
improve dns search and match configuration
mlsmaycon Nov 14, 2022
9636f54
add init linux and pass wg iface
mlsmaycon Nov 14, 2022
3e95a8f
rename configurator
mlsmaycon Nov 15, 2022
35f3a2f
add linux systemd-resolver configurator
mlsmaycon Nov 15, 2022
c058276
sync go.sum
mlsmaycon Nov 15, 2022
983d5be
flush cache and fix correct link interface
mlsmaycon Nov 15, 2022
3b5eb55
use latest dbus version
mlsmaycon Nov 15, 2022
17e0958
use the system bus
mlsmaycon Nov 15, 2022
3289e2b
add mocking configurator
mlsmaycon Nov 15, 2022
94f00f0
probe port before listen and serve
mlsmaycon Nov 15, 2022
25388ad
check if systemd resolver is running and use SetDNS
mlsmaycon Nov 16, 2022
486a9e3
issue proper message for listener
mlsmaycon Nov 16, 2022
ffd071c
issue proper udp listener
mlsmaycon Nov 16, 2022
912aec4
add network manager configurator and split code in different files
mlsmaycon Nov 17, 2022
ef08ca6
add network manager configurator
mlsmaycon Nov 18, 2022
6522265
compare nm version
mlsmaycon Nov 18, 2022
9e44d0c
simplify hostManager interface
mlsmaycon Nov 18, 2022
9ee7405
update system configurator for updated interface
mlsmaycon Nov 18, 2022
6753a39
check socket if not windows
mlsmaycon Nov 18, 2022
b37aa02
updated windows configurator with new interface
mlsmaycon Nov 19, 2022
8aac2aa
adjust logs
mlsmaycon Nov 19, 2022
8561256
update systemd with new interface methods
mlsmaycon Nov 19, 2022
9ad3e7e
rename systemd file
mlsmaycon Nov 19, 2022
0453ae5
use netbird ip for listener
mlsmaycon Nov 19, 2022
84387cd
add installer log
mlsmaycon Nov 20, 2022
c8f9934
use buildRecordKey for local records
mlsmaycon Nov 20, 2022
0288f47
create option map
mlsmaycon Nov 20, 2022
d0c4439
check if values is nil before call
mlsmaycon Nov 20, 2022
b716e45
adjust nm to new interface
mlsmaycon Nov 20, 2022
9c42d23
Merge branch 'main' into feature/dns-client-configuration
mlsmaycon Nov 21, 2022
b33ff4b
add mode check for network manager
mlsmaycon Nov 21, 2022
a990de0
added file configurator
mlsmaycon Nov 21, 2022
85d0e8c
return success when not resolved
mlsmaycon Nov 21, 2022
59ca46a
skip using command to copy file
mlsmaycon Nov 21, 2022
1f27804
fix local tests
mlsmaycon Nov 21, 2022
2e60459
fix docker and lint tests
mlsmaycon Nov 21, 2022
fe85b59
fix codacy checks
mlsmaycon Nov 21, 2022
74948e4
use correct object path and remove device on exit
mlsmaycon Nov 22, 2022
1e7f85d
check if dns server already exist
mlsmaycon Nov 22, 2022
e2e6877
get GUI from WGInterface and handle errors
mlsmaycon Nov 22, 2022
a6d89a1
add missing fmt argument
mlsmaycon Nov 22, 2022
2077675
check if interface exist
mlsmaycon Nov 22, 2022
9c4f08a
create the interface
mlsmaycon Nov 22, 2022
3b82aba
use getDefaultServerWithNoHostManager for tests
mlsmaycon Nov 23, 2022
74bb48d
Merge branch 'main' into feature/dns-client-configuration
mlsmaycon Nov 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use getDefaultServerWithNoHostManager for tests
mlsmaycon committed Nov 23, 2022
commit 3b82aba15db7b4add4b2eaf283df61b8d32afec8
60 changes: 36 additions & 24 deletions client/internal/dns/server_test.go
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ package dns
import (
"context"
"fmt"
"github.com/miekg/dns"
nbdns "github.com/netbirdio/netbird/dns"
"github.com/netbirdio/netbird/iface"
"net"
"net/netip"
"os"
@@ -189,18 +189,8 @@ func TestUpdateDNSServer(t *testing.T) {

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
wgInterface, err := iface.NewWGIFace("utun10000", "100.66.0.32/32", iface.DefaultMTU)
if err != nil {
t.Error(err)
}
_ = wgInterface.Create()
defer wgInterface.Close()
dnsServer := getDefaultServerWithNoHostManager("127.0.0.1")

ctx := context.Background()
dnsServer, err := NewDefaultServer(ctx, wgInterface)
if err != nil {
t.Error(err)
}
dnsServer.hostManager = newNoopHostMocker()

dnsServer.dnsMuxMap = testCase.initUpstreamMap
@@ -209,7 +199,7 @@ func TestUpdateDNSServer(t *testing.T) {
// pretend we are running
dnsServer.listenerIsRunning = true

err = dnsServer.UpdateDNSServer(testCase.inputSerial, testCase.inputUpdate)
err := dnsServer.UpdateDNSServer(testCase.inputSerial, testCase.inputUpdate)
if err != nil {
if testCase.shouldFail {
return
@@ -243,16 +233,8 @@ func TestUpdateDNSServer(t *testing.T) {
}

func TestDNSServerStartStop(t *testing.T) {
ctx := context.Background()
wgInterface, err := iface.NewWGIFace("utun10001", "100.66.0.32/32", iface.DefaultMTU)
if err != nil {
t.Error(err)
}
dnsServer := getDefaultServerWithNoHostManager("127.0.0.1")

dnsServer, err := NewDefaultServer(ctx, wgInterface)
if err != nil {
t.Error(err)
}
if runtime.GOOS == "windows" && os.Getenv("CI") == "true" {
// todo review why this test is not working only on github actions workflows
t.Skip("skipping test in Windows CI workflows.")
@@ -262,7 +244,7 @@ func TestDNSServerStartStop(t *testing.T) {

dnsServer.Start()

err = dnsServer.localResolver.registerRecord(zoneRecords[0])
err := dnsServer.localResolver.registerRecord(zoneRecords[0])
if err != nil {
t.Error(err)
}
@@ -299,10 +281,40 @@ func TestDNSServerStartStop(t *testing.T) {
}

dnsServer.Stop()
ctx, cancel := context.WithTimeout(ctx, time.Second*1)
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*1)
defer cancel()
_, err = resolver.LookupHost(ctx, zoneRecords[0].Name)
if err == nil {
t.Fatalf("we should encounter an error when querying a stopped server")
}
}

func getDefaultServerWithNoHostManager(ip string) *DefaultServer {
mux := dns.NewServeMux()
listenIP := defaultIP
if ip != "" {
listenIP = ip
}

dnsServer := &dns.Server{
Addr: fmt.Sprintf("%s:%d", ip, port),
Net: "udp",
Handler: mux,
UDPSize: 65535,
}

ctx, stop := context.WithCancel(context.TODO())

return &DefaultServer{
ctx: ctx,
stop: stop,
server: dnsServer,
dnsMux: mux,
dnsMuxMap: make(registrationMap),
localResolver: &localResolver{
registeredMap: make(registrationMap),
},
runtimePort: port,
runtimeIP: listenIP,
}
}