Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wtfnode

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wtfnode - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

66

index.js

@@ -452,2 +452,39 @@ 'use strict';

function getProtocol(req, socket) {
if (typeof req.protocol === 'string') return req.protocol;
var agent = req.agent;
if (typeof agent.protocol === 'string') return agent.protocol;
var ctor = socket.constructor && socket.constructor.name;
return ctor === 'CleartextStream' ? 'https:' : 'http:';
}
function getHost(req) {
if (typeof req.host === 'string') return req.host;
if (typeof req.getHeader !== 'function') return 'unknown';
var hostHeader = req.getHeader('host');
if (typeof hostHeader === 'string') return hostHeader;
return '(unknown)';
}
function getPort(socket, host, protocol) {
if (typeof socket.remotePort === 'number') return socket.remotePort;
var match = host.match(/:(\d+)$/);
if (match) {
var port = parseInt(match[1], 10);
if (!isNaN(match)) return port;
}
return protocol === 'https:' ? 443 : 80;
}
function getHttpInfo(socket) {
var req = socket._httpMessage || {};
var method = req.method || 'unknown';
var protocol = getProtocol(req, socket);
var host = getHost(req);
var port = getPort(socket, host, protocol);
var path = req.path || 'unknown';
host = host.replace(/:\d+$/, '');
if ((protocol === 'https:' && port !== 443) || (protocol === 'http:' && port !== 80)) {
host += ':' + port;
}
return { method: method, protocol: protocol, host: host, port: port, path: path };
}
function dump() {

@@ -564,28 +601,5 @@ log('info', '[WTF Node?] open handles:');

}
if(s._httpMessage) {
var req = s._httpMessage || {};
var agent = req.agent || {};
var method = req.method || 'unknown';
var host = req.host || req.getHeader('host').replace(/:\d+$/, '');
var path = req.path || 'unknown';
var protocol = req.protocol || agent.protocol || (function () {
var ctor = s.constructor && s.constructor.name;
return ctor === 'CleartextStream' ? 'https:' : 'http:';
})() || 'unknown';
var port = s.remotePort || (protocol === 'https:' ? 443 : 80);
if (protocol === 'https:' && port !== 443) {
host += ':' + port;
} else if (protocol === 'http:' && port !== 80) {
host += ':' + port;
}
if (host.indexOf(':') > -1) {
if (/:443/.test(host) && protocol === 'https:') {
host = host.replace(/:443$/, '');
} else if (/:80/.test(host) && protocol === 'http:') {
host = host.replace(/:80$/, '');
}
}
log('info', ' - %s %s//%s%s', method, protocol, host, path);
if (s._httpMessage) {
var i = getHttpInfo(s);
log('info', ' - %s %s//%s%s', i.method, i.protocol, i.host, i.path);
}

@@ -592,0 +606,0 @@ var connectListeners = s.listeners('connect');

{
"name": "wtfnode",
"version": "0.9.2",
"version": "0.9.3",
"description": "Utility to help find out why Node isn't exiting",

@@ -16,3 +16,3 @@ "repository": {

"scripts": {
"test": "(cd tests && node test && node test-eval && node test-promise && node test-promisify && node test-logging && node test-once-flowing && node test-issue-37.js && node test-no-source-map-support && node test-broken-source-map-support && node test-http-client)",
"test": "(cd tests && node test && node test-eval && node test-promise && node test-promisify && node test-logging && node test-once-flowing && node test-issue-37.js && node test-no-source-map-support && node test-broken-source-map-support && node test-http-client && node test-http-info)",
"test-sourcemaps": "(cd tests && coffee --map --compile test-sourcemaps.coffee && node test-sourcemaps.js || exit 0)",

@@ -19,0 +19,0 @@ "kitchensink": "(cd tests && node kitchensink)"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc