-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add redirect support (limit: 6) #29
base: master
Are you sure you want to change the base?
Conversation
Resolves issue #25.
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! Added some minor feedback
README.md
Outdated
@@ -39,6 +39,9 @@ datDns.resolveName('foo.com', {noDnsOverHttps: true}) | |||
// dont use .well-known/dat | |||
datDns.resolveName('foo.com', {noWellknownDat: true}) | |||
|
|||
// specify amount of redirects (default: 7) |
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.
Is it 7 or 6? (Just looking at the constant in index.js)
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.
Its 6, fixed in ed33316
index.js
Outdated
@@ -69,6 +70,7 @@ function createDatDNS (datDnsOpts) { | |||
var ignoreCachedMiss = opts && opts.ignoreCachedMiss | |||
var noDnsOverHttps = opts && opts.noDnsOverHttps | |||
var noWellknownDat = opts && opts.noWellknownDat | |||
var followRedirects = (opts && opts.followRedirects) || DEFAULT_FOLLOW_REDIRECTS |
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.
Could we modify this so that 0
is allowed?
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.
added support & test in 7a488de - thanks for noticing.
index.js
Outdated
if ([301, 302, 307, 308].includes(res.statusCode)) { | ||
if (!'location' in res.headers) { | ||
debug('.well-known/' + recordName + ' lookup redirect did not contain destination Location header.') | ||
throw new Error('Well record redirected to nowhere') |
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.
Minor typo in this error description
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.
I adjust both this and the next error message in 7edfc1b
index.js
Outdated
// resolve relative paths with original URL as base URL | ||
const uri = new URL(res.headers['location'], 'https://' + host) | ||
if (uri.protocol !== 'https:') { | ||
throw new Error('DNS record redirected to non https: protocol: ' + uri.href) |
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.
Was it the DNS record or the HTTP response?
Improved implementation of #27. I used the findings of #27 and restructured the changes a bit, fixing a few things:
.well-known
for the first request (but not redirects)Closes #25