Browse Source

fix localnameserver creation

pull/1173/head
Darien Raymond 7 years ago
parent
commit
c9e35bb1ba
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 8
      app/dns/nameserver.go
  2. 4
      app/dns/server.go
  3. 2
      vendor/websocket

8
app/dns/nameserver.go

@ -10,11 +10,11 @@ type NameServer interface {
QueryIP(ctx context.Context, domain string) ([]net.IP, error)
}
type LocalNameServer struct {
type localNameServer struct {
resolver net.Resolver
}
func (s *LocalNameServer) QueryIP(ctx context.Context, domain string) ([]net.IP, error) {
func (s *localNameServer) QueryIP(ctx context.Context, domain string) ([]net.IP, error) {
ipAddr, err := s.resolver.LookupIPAddr(ctx, domain)
if err != nil {
return nil, err
@ -26,8 +26,8 @@ func (s *LocalNameServer) QueryIP(ctx context.Context, domain string) ([]net.IP,
return ips, nil
}
func NewLocalNameServer() *LocalNameServer {
return &LocalNameServer{
func NewLocalNameServer() *localNameServer {
return &localNameServer{
resolver: net.Resolver{
PreferGo: true,
},

4
app/dns/server.go

@ -44,7 +44,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
for idx, destPB := range config.NameServers {
address := destPB.Address.AsAddress()
if address.Family().IsDomain() && address.Domain() == "localhost" {
server.servers[idx] = &LocalNameServer{}
server.servers[idx] = NewLocalNameServer()
} else {
dest := destPB.AsDestination()
if dest.Network == net.Network_Unknown {
@ -56,7 +56,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
}
}
if len(config.NameServers) == 0 {
server.servers = append(server.servers, &LocalNameServer{})
server.servers = append(server.servers, NewLocalNameServer())
}
return server, nil

2
vendor/websocket vendored

@ -1 +1 @@
Subproject commit 17ef924799bd76d2e939bb6ccf8356bdfb19671d
Subproject commit 353d1e4e044e28bcf2ce8dccd9056bfd3385dbb8
Loading…
Cancel
Save