Skip to content

Commit

Permalink
A more robust check for rinfo.family since in some node version/os ri…
Browse files Browse the repository at this point in the history
…nfo family returned value could be number.
  • Loading branch information
dadepo committed May 11, 2022
1 parent 27bdd26 commit f620185
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/transport/udp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export class UDPTransportService
}

public handleIncoming = (data: Buffer, rinfo: IRemoteInfo): void => {
const multiaddr = new Multiaddr(`/${rinfo.family === "IPv4" ? "ip4" : "ip6"}/${rinfo.address}/udp/${rinfo.port}`);
const multiaddr = new Multiaddr(
`/${String(rinfo.family).endsWith("4") ? "ip4" : "ip6"}/${rinfo.address}/udp/${rinfo.port}`
);
try {
const packet = decodePacket(this.srcId, data);
this.emit("packet", multiaddr, packet);
Expand Down

0 comments on commit f620185

Please sign in to comment.