From 7331fbcb81c998cdebe4e540b64d6a8c9f3c7ef3 Mon Sep 17 00:00:00 2001 From: dadepo Date: Thu, 12 May 2022 13:39:02 +0200 Subject: [PATCH] fix: A more robust check for rinfo.family (#178) * fix: A more robust check for rinfo.family. * ci: update node version --- .github/workflows/test_and_release.yml | 2 +- src/transport/udp.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml index 4c9aeeb0..77ae9e08 100644 --- a/.github/workflows/test_and_release.yml +++ b/.github/workflows/test_and_release.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-latest] - node: [15, 16] + node: [16, 17, 18] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2-beta diff --git a/src/transport/udp.ts b/src/transport/udp.ts index ec8ae310..f5a2ebe1 100644 --- a/src/transport/udp.ts +++ b/src/transport/udp.ts @@ -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);