Skip to content

added IP in output#16

Open
svenflender wants to merge 1 commit intowatson:masterfrom
svenflender:master
Open

added IP in output#16
svenflender wants to merge 1 commit intowatson:masterfrom
svenflender:master

Conversation

@svenflender
Copy link

Hi,

i added the IP Address in the output. Is sometimes very useful!

Thx for the great Tool!
Best Regards
Sven

var Trace = require('..')
var chalk = require('chalk')
const url = require('url');
const dns = require('dns-sync');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments