brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

Build window fail #201

Closed zuozhehao closed 2 years ago

zuozhehao commented 3 years ago
DEBUG 2021/06/11 09:05:33 main.go:39: Switch is on
INFO 2021/06/11 09:05:33 ip_transport.go:184: Listening on port 12345
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x57244d]

goroutine 9 [running]:
github.com/brutella/dnssd.(*Service).IPsAtInterface(0xc0000756c0, 0x0, 0xc0001b6320, 0x4, 0x6cb924)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/service.go:150 +0x4d
github.com/brutella/dnssd.A(0xc0001b6320, 0x4, 0x6cb924, 0x9, 0x6ca58d, 0x5, 0xc0001b6324, 0xc, 0xc0001acd20, 0x0, ...)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/dns.go:116 +0x5f
github.com/brutella/dnssd.containsConflictingAnswers(0xc000004be8, 0xc0000064b0, 0x31a64c)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/responder.go:465 +0xc5
github.com/brutella/dnssd.findConflicts(0xc000004be8, 0xc0003b8010, 0x1, 0x1, 0x2, 0x2, 0xc000075b38)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/responder.go:446 +0xa5
github.com/brutella/dnssd.(*responder).handleRequest(0xc00012a780, 0xc000004be8)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/responder.go:238 +0x99
github.com/brutella/dnssd.(*responder).respond(0xc00012a780, 0x747718, 0xc00005ab40, 0x0, 0x0)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/responder.go:203 +0x19d
github.com/brutella/dnssd.(*responder).Respond(0xc00012a780, 0x747718, 0xc00005ab40, 0x0, 0x0)
    D:/*******/pkg/mod/github.com/brutella/dnssd@v1.2.0/responder.go:113 +0x48c
github.com/brutella/hc.(*ipTransport).Start.func1(0xc00012e240, 0x747718, 0xc00005ab40, 0xc0000618c0)
    D:/*******/pkg/mod/github.com/brutella/hc@v1.2.4/ip_transport.go:168 +0x59
created by github.com/brutella/hc.(*ipTransport).Start
    D:/*******/pkg/mod/github.com/brutella/hc@v1.2.4/ip_transport.go:167 +0x327

Process finished with the exit code 2
zuozhehao commented 3 years ago

I tried to add a length judgment to solve the problem

https://github.com/brutella/dnssd/blob/master/service.go#L150-L152

if len(s.ifaceIPs) > 0 {
  if ips, ok := s.ifaceIPs[iface.Name]; ok {
    return ips
  }
}
brutella commented 2 years ago

This should be fixed by now.