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

Commit c8cae5b

Browse files
committed
Do note throw if localAddress is fqdn
1 parent 2593f87 commit c8cae5b

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
@@ -104,7 +104,11 @@ module.exports = (socket, options = {}) => {
104104
* @returns {Multiaddr|undefined}
105105
*/
106106
function toLocalAddr (socket) {
107-
return socket.localAddress && socket.localPort
108-
? toMultiaddr(socket.localAddress, socket.localPort)
109-
: undefined
107+
if (socket.localAddress && socket.localPort) {
108+
try {
109+
return toMultiaddr(socket.localAddress, socket.localPort)
110+
} catch {
111+
// Might fail if the socket.localAddress is fqdn
112+
}
113+
}
110114
}

0 commit comments

Comments
 (0)