Skip to content

Commit

Permalink
Merge pull request #35 from rblenkinsopp/nil-interface-fixes
Browse files Browse the repository at this point in the history
Check for nil interfaces on various functions
  • Loading branch information
brutella authored Jul 4, 2022
2 parents 47aa1cf + 0923f3c commit 035b35b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func NSEC(rr dns.RR, srv Service, iface *net.Interface) *dns.NSEC {
}

func A(srv Service, iface *net.Interface) []*dns.A {
if iface == nil {
return []*dns.A{}
}

ips := srv.IPsAtInterface(iface)

var as []*dns.A
Expand All @@ -135,6 +139,10 @@ func A(srv Service, iface *net.Interface) []*dns.A {
}

func AAAA(srv Service, iface *net.Interface) []*dns.AAAA {
if iface == nil {
return []*dns.AAAA{}
}

ips := srv.IPsAtInterface(iface)

var aaaas []*dns.AAAA
Expand Down
4 changes: 4 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ func (s *Service) Interfaces() []*net.Interface {

// IPsAtInterface returns the ip address at a specific interface.
func (s *Service) IPsAtInterface(iface *net.Interface) []net.IP {
if iface == nil {
return []net.IP{}
}

if ips, ok := s.ifaceIPs[iface.Name]; ok {
return ips
}
Expand Down

0 comments on commit 035b35b

Please sign in to comment.