Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit b8729b9

Browse files
committed
Do note throw if localAddress is fqdn
1 parent 1d3ad76 commit b8729b9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/socket-to-conn.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ module.exports = (socket, options = {}) => {
103103
* @returns {Multiaddr|undefined}
104104
*/
105105
function toLocalAddr(socket) {
106-
return socket.localAddress && socket.localPort
107-
? toMultiaddr(socket.localAddress, socket.localPort)
108-
: undefined;
106+
if (socket.localAddress && socket.localPort) {
107+
try {
108+
toMultiaddr(socket.localAddress, socket.localPort)
109+
} catch {
110+
// Might fail if the socket.localAddress is fqdn
111+
}
112+
}
109113
}

0 commit comments

Comments
 (0)