mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-30 03:54:35 +01:00
30 lines
481 B
Go
30 lines
481 B
Go
|
package dns
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
mutex sync.Mutex
|
||
|
server Server
|
||
|
)
|
||
|
|
||
|
// GetServerDns export the DNS server instance in static way. It used by the Mobile client
|
||
|
func GetServerDns() (Server, error) {
|
||
|
mutex.Lock()
|
||
|
if server == nil {
|
||
|
mutex.Unlock()
|
||
|
return nil, fmt.Errorf("DNS server not instantiated yet")
|
||
|
}
|
||
|
s := server
|
||
|
mutex.Unlock()
|
||
|
return s, nil
|
||
|
}
|
||
|
|
||
|
func setServerDns(newServerServer Server) {
|
||
|
mutex.Lock()
|
||
|
server = newServerServer
|
||
|
defer mutex.Unlock()
|
||
|
}
|