-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for localaddress #1659
Conversation
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 17.0.45 to 18.0.3. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Codecov ReportBase: 94.89% // Head: 94.19% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1659 +/- ##
==========================================
- Coverage 94.89% 94.19% -0.71%
==========================================
Files 53 53
Lines 4803 4960 +157
==========================================
+ Hits 4558 4672 +114
- Misses 245 288 +43
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The PR is overall ready for review, I'm having a few struggles trying to test it as by default the Any good hint about how to test this properly? 🙂 |
what error are you facing? |
`EINVAL ::1` for IPV6✖ bind EINVAL ::1 test: basic connect with localaddress I can keep it with
Didn't check that yet, I'll do that tomorrow 👍 |
Is it? |
Yes, at least at my machine. The socket is automatically resolving to Sample`Ignore the DNS, I was playing around to see if maybe the IPV6 was not being resolved locally`test('basic connect with localaddress', { only: true }, (t) => {
t.plan(4)
const server = http.createServer((c) => {
t.fail()
})
server.on('connect', (req, socket, firstBodyChunk) => {
socket.write('HTTP/1.1 200 Connection established\r\n\r\n')
let data = firstBodyChunk.toString()
socket.on('data', (buf) => {
data += buf.toString()
})
socket.on('end', () => {
socket.end(data)
})
})
t.teardown(server.close.bind(server))
dns.lookup('localhost', { family: 6 }, (err, address) => {
if (err) t.fail(err)
server.listen(0, async () => {
const client = new Client(`http://localhost:${server.address().port}`, {
// localAddress: '127.0.0.1'
})
t.teardown(client.close.bind(client))
const signal = new EE()
const promise = client.connect({
signal,
path: '/'
})
t.equal(signal.listenerCount('abort'), 1)
const { socket } = await promise
t.equal(signal.listenerCount('abort'), 0)
t.equal(socket.localAddress, 'wrong-input')
let recvData = ''
socket.on('data', (d) => {
recvData += d
})
socket.on('end', () => {
t.equal(recvData.toString(), 'Body')
})
socket.write('Body')
socket.end()
})
})
}) |
Are you sure there is an IPv6 network on your machine? |
It's enabled and set default to So, not 100% how to test it |
test/client-errors.js
Outdated
@@ -299,12 +299,22 @@ test('invalid options throws', (t) => { | |||
|
|||
try { | |||
new Client(new URL('http://localhost:200'), { // eslint-disable-line | |||
keepAliveTimeout: 'asd' |
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.
Why did you remove this?
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.
Finger error, brought back in 82c2025 🙂
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
* build(deps-dev): bump @types/node from 17.0.45 to 18.0.3 (#10) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 17.0.45 to 18.0.3. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add support for localaddress * tests: add testing * revert: missed test Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps-dev): bump @types/node from 17.0.45 to 18.0.3 (nodejs#10) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 17.0.45 to 18.0.3. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add support for localaddress * tests: add testing * revert: missed test Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This relates to...
Rationale
Changes
Features
localAddress
by forwarding the option to thenet.Socket#connect
method.Bug Fixes
Breaking Changes and Deprecations
Status
KEY: S = Skipped, x = complete