Skip to content

Commit

Permalink
fix: A more robust check for rinfo.family.
Browse files Browse the repository at this point in the history
  • Loading branch information
dadepo committed May 11, 2022
1 parent 27bdd26 commit 243a8cd
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 243a8cd

Please sign in to comment.