Conversation
jhermsmeier
reviewed
Mar 11, 2020
| var Trace = require('..') | ||
| var chalk = require('chalk') | ||
| const url = require('url'); | ||
| const dns = require('dns-sync'); |
Contributor
There was a problem hiding this comment.
The dns-sync isn't a core module – looks like you forgot to add this to the package.json.
Also, the dns-sync module spawns a new node process through shelljs for each resolve – I'm not sure how desirable that is, compared to just using the core's dns module and deal with the asynchrony.
Contributor
There was a problem hiding this comment.
Thinking about this a moment longer, there's no need to this at all, as the remote address is available through the response socket, so all that's needed would be the following:
diff --git a/bin/cli.js b/bin/cli.js
index d71a9c2..bb431ad 100755
--- a/bin/cli.js
+++ b/bin/cli.js
@@ -19,6 +19,7 @@ var trace = new Trace(process.argv[2])
chalk.yellow(step.protocol + '/' + step.protocolVersionMajor + '.' + step.protocolVersionMinor),
chalk.gray(step.method),
step.url,
+ chalk.red(step.remoteAddress),
chalk.gray(step.newCookies ? '(cookies: ' + step.newCookies + ') ' : '') +
chalk.cyan('(' + step.time + ' ms)')
)
diff --git a/lib/trace.js b/lib/trace.js
index a7b1a6a..8d33edf 100755
--- a/lib/trace.js
+++ b/lib/trace.js
@@ -131,6 +131,7 @@ Object.assign(Trace.prototype, {
self.statusCode = res.statusCode
self.push({
+ remoteAddress: res.socket.remoteAddress,
protocol: res.protocol,
protocolVersionMajor: res.httpVersionMajor,
protocolVersionMinor: res.httpVersionMinor,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi,
i added the IP Address in the output. Is sometimes very useful!
Thx for the great Tool!
Best Regards
Sven