Skip to content

Commit

Permalink
Default to nil ips and port 4001 if no dialable found
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Oct 12, 2022
1 parent 9bcb802 commit 0be2816
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions internal/mdns/dialable.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ var (
ErrTCPListenAddressNotFound = errors.New("TCP listen address not found")
)

func getMDNSIPsAndPort(p2pHost Networker) (ips []net.IP, port uint16, err error) {
func getMDNSIPsAndPort(p2pHost Networker) (ips []net.IP, port uint16) {
tcpAddresses, err := getDialableListenAddrs(p2pHost)
if err != nil {
return nil, 0, fmt.Errorf("getting dialable listen addresses: %w", err)
const defaultPort = 4001
return nil, defaultPort
}

ips = make([]net.IP, len(tcpAddresses))
Expand All @@ -27,7 +28,7 @@ func getMDNSIPsAndPort(p2pHost Networker) (ips []net.IP, port uint16, err error)
}
port = uint16(tcpAddresses[0].Port)

return ips, port, nil
return ips, port
}

func getDialableListenAddrs(p2pHost Networker) (tcpAddresses []*net.TCPAddr, err error) {
Expand Down
5 changes: 1 addition & 4 deletions internal/mdns/mdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ func NewService(p2pHost IDNetworker, serviceTag string,

// Start starts the mDNS service.
func (s *Service) Start() (err error) {
ips, port, err := getMDNSIPsAndPort(s.p2pHost)
if err != nil {
return fmt.Errorf("getting MDNS ips and port: %w", err)
}
ips, port := getMDNSIPsAndPort(s.p2pHost)

hostID := s.p2pHost.ID()

Expand Down

0 comments on commit 0be2816

Please sign in to comment.