-
Notifications
You must be signed in to change notification settings - Fork 1
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: dns interceptor #5
base: main
Are you sure you want to change the base?
Conversation
9d60ded
to
8d01c27
Compare
8d01c27
to
85fb94d
Compare
// TODO (fix): What about old "blacklisted" records? | ||
// TODO (fix): What about ipv6? | ||
|
||
records = await resolve4(hostname, { ttl: true }) |
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.
if there's no entry in the dnsCache, and multiple requests are made, it will create many concurrent records - possibly an issue?
also perhaps use stale-while-revalidate?
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.
can avsolulety be more optimized. I'll have a look
const record = records.find((record) => record.expires > now) | ||
|
||
if (!record) { | ||
return dispatch(opts, handler) | ||
} |
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.
not sure I follow this, it was already checked at top?
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.
checked where?
|
||
const { protocol, port, hostname, host } = new URL(opts.origin) | ||
|
||
if (net.isIP(hostname) || opts.headers?.host || !port || !protocol) { |
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 skip when headers.host or !port?
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.
We should always have port and protocol so I guess I should change that to an asser ot default to http:80.
If a host header is set I'm not sure what kind of weird issues it can cause.
{ | ||
...opts, | ||
origin: `${protocol}//${record.address}:${port}`, | ||
headers: { ...opts.headers, host }, |
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 set host header?
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.
Because otherwise the host header will have the ip instead of the dns name which will cause issues.
No description provided.