lib: use Node.js net lib and reject malformed addresses #144
+166
−63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #143. Given the current API of this library, I believe that it's not suitable to support malformed addresses like
0x7f.1
. It's hard to parse them correctly in all cases. It's better to throw errors for them.This PR uses the Node.js
net
library so it should be reliable.I suggest releasing v3 after merging this, because:
net.SocketAddress
is added in Node v15.14.0 and v14.18.0. I think it's reasonable to drop support for older Node versions because Node 12 has reached end-of-life since 2022-04-30. If the user cares about security, they should use a new Node version.We could try to (partially) fix the security concerns in a compatible way in v2 (and v1) in another pull request.