2022-11-07 15:38:21 +01:00
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-11-02 19:04:33 +01:00
|
|
|
|
2024-12-10 11:03:40 +01:00
|
|
|
"github.com/netbirdio/netbird/client/internal/routemanager/dnsinterceptor"
|
2022-11-07 15:38:21 +01:00
|
|
|
nbdns "github.com/netbirdio/netbird/dns"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MockServer is the mock instance of a dns server
|
|
|
|
type MockServer struct {
|
2023-06-15 12:25:18 +02:00
|
|
|
InitializeFunc func() error
|
2022-11-07 15:38:21 +01:00
|
|
|
StopFunc func()
|
|
|
|
UpdateDNSServerFunc func(serial uint64, update nbdns.Config) error
|
|
|
|
}
|
|
|
|
|
2024-12-10 11:03:40 +01:00
|
|
|
func (m *MockServer) RegisterHandler(*dnsinterceptor.RouteMatchHandler) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-06-15 12:25:18 +02:00
|
|
|
// Initialize mock implementation of Initialize from Server interface
|
|
|
|
func (m *MockServer) Initialize() error {
|
|
|
|
if m.InitializeFunc != nil {
|
|
|
|
return m.InitializeFunc()
|
2022-11-07 15:38:21 +01:00
|
|
|
}
|
2023-06-15 12:25:18 +02:00
|
|
|
return nil
|
2022-11-07 15:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stop mock implementation of Stop from Server interface
|
|
|
|
func (m *MockServer) Stop() {
|
|
|
|
if m.StopFunc != nil {
|
|
|
|
m.StopFunc()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-12 14:43:55 +02:00
|
|
|
func (m *MockServer) DnsIP() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
func (m *MockServer) OnUpdatedHostDNSServer(strings []string) {
|
2023-12-18 11:46:58 +01:00
|
|
|
// TODO implement me
|
2023-07-14 21:56:22 +02:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-11-07 15:38:21 +01:00
|
|
|
// UpdateDNSServer mock implementation of UpdateDNSServer from Server interface
|
|
|
|
func (m *MockServer) UpdateDNSServer(serial uint64, update nbdns.Config) error {
|
|
|
|
if m.UpdateDNSServerFunc != nil {
|
|
|
|
return m.UpdateDNSServerFunc(serial, update)
|
|
|
|
}
|
|
|
|
return fmt.Errorf("method UpdateDNSServer is not implemented")
|
|
|
|
}
|
2023-11-02 19:04:33 +01:00
|
|
|
|
|
|
|
func (m *MockServer) SearchDomains() []string {
|
|
|
|
return make([]string, 0)
|
|
|
|
}
|
2024-01-23 17:23:12 +01:00
|
|
|
|
|
|
|
// ProbeAvailability mocks implementation of ProbeAvailability from the Server interface
|
|
|
|
func (m *MockServer) ProbeAvailability() {
|
|
|
|
}
|