Skip to content

Commit 0be2816

Browse files
committed
Default to nil ips and port 4001 if no dialable found
1 parent 9bcb802 commit 0be2816

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

internal/mdns/dialable.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ var (
1515
ErrTCPListenAddressNotFound = errors.New("TCP listen address not found")
1616
)
1717

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

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

30-
return ips, port, nil
31+
return ips, port
3132
}
3233

3334
func getDialableListenAddrs(p2pHost Networker) (tcpAddresses []*net.TCPAddr, err error) {

internal/mdns/mdns.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ func NewService(p2pHost IDNetworker, serviceTag string,
4949

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

5754
hostID := s.p2pHost.ID()
5855

0 commit comments

Comments
 (0)