Skip to content

Commit

Permalink
fix: A more robust check for rinfo.family (#178)
Browse files Browse the repository at this point in the history
* fix: A more robust check for rinfo.family.

* ci: update node version
  • Loading branch information
dadepo committed May 12, 2022
1 parent 27bdd26 commit 7331fbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 7331fbc

Please sign in to comment.