From 369b0504137cf96c2ad2cb537afcfe132f166f07 Mon Sep 17 00:00:00 2001 From: wuchangming Date: Mon, 21 Mar 2016 13:22:42 +0800 Subject: [PATCH] ip bugs --- lib/proxy/SpyProxy.js | 4 +++- package.json | 3 ++- src/proxy/SpyProxy.js | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/proxy/SpyProxy.js b/lib/proxy/SpyProxy.js index 35c3e32..89f6e59 100644 --- a/lib/proxy/SpyProxy.js +++ b/lib/proxy/SpyProxy.js @@ -15,6 +15,8 @@ var debug = require('debug')('spy-debugger'); var config = require('../config/config'); var logColor = config.logColor; var domain = require('domain'); +var ip = require('ip'); +var address = ip.address(); module.exports = function () { function SpyProxy(options) { @@ -46,7 +48,7 @@ module.exports = function () { }); }); }); - console.log(logColor.FgGreen + '%s' + logColor.Reset, '移动设备设置HTTP代理到本机。本机IP地址:' + os.networkInterfaces().en0[1].address + ',端口号为:' + port); + console.log(logColor.FgGreen + '%s' + logColor.Reset, '移动设备设置HTTP代理到本机。本机IP地址:' + address + ',端口号为:' + port); } }, { key: 'requestHandler', diff --git a/package.json b/package.json index 89dc122..80dfd57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spy-debugger", - "version": "1.0.0", + "version": "1.0.1", "description": "web page one-stop remote network debugger", "main": "lib/index.js", "scripts": { @@ -28,6 +28,7 @@ "dependencies": { "commander": "^2.9.0", "debug": "^2.2.0", + "ip": "^1.1.2", "through2": "^2.0.1", "weinre": "2.0.0-pre-I0Z7U9OV" }, diff --git a/src/proxy/SpyProxy.js b/src/proxy/SpyProxy.js index 7c266f7..aae3df4 100644 --- a/src/proxy/SpyProxy.js +++ b/src/proxy/SpyProxy.js @@ -11,6 +11,8 @@ const debug = require('debug')('spy-debugger'); const config = require('../config/config'); const logColor = config.logColor; const domain = require('domain'); +const ip = require('ip'); +var address = ip.address(); module.exports = class SpyProxy { constructor(options) { @@ -35,7 +37,7 @@ module.exports = class SpyProxy { }); }); }); - console.log(`${logColor.FgGreen}%s${logColor.Reset}`,`移动设备设置HTTP代理到本机。本机IP地址:${os.networkInterfaces().en0[1].address},端口号为:${port}`); + console.log(`${logColor.FgGreen}%s${logColor.Reset}`,`移动设备设置HTTP代理到本机。本机IP地址:${address},端口号为:${port}`); } requestHandler(req, res) { var urlObject = url.parse(req.url);