-
Notifications
You must be signed in to change notification settings - Fork 5
feat: is multiaddr private and loopback #10
Conversation
88fe5c4
to
d4e08a9
Compare
@jacobheun I created a module is-loopback-addr with a more specific check for verifying loopback addresses and added it. Also structured the utils as you suggested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, just two things:
- Add the utilities to the README so they're easy to find.
- Can we add some tests for multiaddrs without IPs? (dns4, etc) Do these functions throw if there is no IP?
86828d5
to
16cd63c
Compare
I added docs and more tests to both. I noticed other utils had no docs (nor jsdocs) and I will add them in a follow up PR.
Yes, they throw if they are not a network address with |
16cd63c
to
dc8fe01
Compare
dc8fe01
to
b47bf6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the headers in the readme are off though.
README.md
Outdated
|
||
Check if a given multiaddr is a loopback address. | ||
|
||
##### Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the following headers are off (too many #'s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks for noticing! fixed it
This PR adds multiaddr
isPrivate
andisLoopback
utilities that can be used for libp2p core and libp2p users to validate if a multiaddr address is a private/loopback network address. This will be useful for creating multiaddr sorters and filtering for dialling and advertising purposes.Unfortunately, the already installed ip-address module does not support this for
ipv4
andipv6
. As a consequence, the private-ip module was added. It has 706 Bytes minified and 312 Bytes minified and gzipped per bundlephobia, which is fine. A is-loopback-addr module was also created for a more specific check.