Skip to content

Commit

Permalink
chore: migrate to is-ip 4.0.0 (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths authored Oct 28, 2022
1 parent 43a87ca commit e2cf4ac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"dgram": "^1.0.1",
"err-code": "^3.0.1",
"ip6addr": "^0.2.3",
"is-ip": "^3.1.0",
"is-ip": "^4.0.0",
"rlp": "^2.2.6",
"strict-event-emitter-types": "^2.0.0",
"varint": "^6.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/message/encode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as RLP from "rlp";
import { multiaddr } from "@multiformats/multiaddr";
import isIp from "is-ip";
import { isIPv4 } from "is-ip";

import {
IPingMessage,
Expand Down Expand Up @@ -56,7 +56,7 @@ export function encodePingMessage(m: IPingMessage): Buffer {
}

export function encodePongMessage(m: IPongMessage): Buffer {
const ipMultiaddr = multiaddr(`/${isIp.v4(m.recipientIp) ? "ip4" : "ip6"}/${m.recipientIp}`);
const ipMultiaddr = multiaddr(`/${isIPv4(m.recipientIp) ? "ip4" : "ip6"}/${m.recipientIp}`);
const tuple = ipMultiaddr.tuples()[0][1];
if (!tuple) {
throw new Error("invalid address for encoding");
Expand Down
4 changes: 2 additions & 2 deletions src/service/addrVotes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isIp from "is-ip";
import { isIPv4 } from "is-ip";
import { NodeId } from "../enr/index.js";

type MultiaddrStr = string;
Expand All @@ -21,7 +21,7 @@ export class AddrVotes {
voter: NodeId,
{ recipientIp, recipientPort }: { recipientIp: string; recipientPort: number }
): { multiaddrStr: string } | undefined {
const multiaddrStr = `/${isIp.v4(recipientIp) ? "ip4" : "ip6"}/${recipientIp}/udp/${recipientPort}`;
const multiaddrStr = `/${isIPv4(recipientIp) ? "ip4" : "ip6"}/${recipientIp}/udp/${recipientPort}`;

const prevVote = this.votes.get(voter);
if (prevVote?.multiaddrStr === multiaddrStr) {
Expand Down
15 changes: 5 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2382,11 +2382,6 @@ ip-regex@^2.1.0:
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9"
integrity sha512-58yWmlHpp7VYfcdTwMTvwMmqx/Elfxjd9RXTDyMsbL7lLWmhMylLEqiYVLKuLzOZqVgiWXD9MfR62Vv89VRxkw==

ip-regex@^4.0.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5"
integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==

ip-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-5.0.0.tgz#cd313b2ae9c80c07bd3851e12bf4fa4dc5480632"
Expand Down Expand Up @@ -2483,12 +2478,12 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1:
dependencies:
is-extglob "^2.1.1"

is-ip@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-3.1.0.tgz#2ae5ddfafaf05cb8008a62093cf29734f657c5d8"
integrity sha512-35vd5necO7IitFPjd/YBeqwWnyDWbuLH9ZXQdMfDA8TEo7pv5X8yfrvVO3xbJbLUlERCMvf6X0hTUamQxCYJ9Q==
is-ip@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-4.0.0.tgz#8e9eae12056bf46edafad19054dcc3666a324b3a"
integrity sha512-4B4XA2HEIm/PY+OSpeMBXr8pGWBYbXuHgjMAqrwbLO3CPTCAd9ArEJzBUKGZtk9viY6+aSfadGnWyjY3ydYZkw==
dependencies:
ip-regex "^4.0.0"
ip-regex "^5.0.0"

is-ip@^5.0.0:
version "5.0.0"
Expand Down

0 comments on commit e2cf4ac

Please sign in to comment.