Skip to content

Commit 4119422

Browse files
aleksandrs-ledovskisjoeferner
authored andcommitted
Default listen on 'localhost'
Quoting Node `server.listen` documentation > If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise. > In most operating systems, listening to the unspecified IPv6 address (::) may cause the net.Server to also listen on the unspecified IPv4 address (0.0.0.0). The broad bind to all interfaces is unsecure default, so better the user/developer provide explicit confirmation of this configuration.
1 parent 00883cf commit 4119422

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ __Arguments__
119119

120120
* options - An object with the following options:
121121
* port - The port or named socket to listen on (default: 8080).
122-
* host - The hostname or local address to listen on.
122+
* host - The hostname or local address to listen on (default: 'localhost'). Pass '::' to listen on all IPv4/IPv6 interfaces.
123123
* sslCaDir - Path to the certificates cache directory (default: process.cwd() + '/.http-mitm-proxy')
124124
* keepAlive - enable [HTTP persistent connection](https://en.wikipedia.org/wiki/HTTP_persistent_connection)
125125
* timeout - The number of milliseconds of inactivity before a socket is presumed to have timed out. Defaults to no timeout.

lib/proxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Proxy.prototype.listen = function(options, callback = e => {}) {
4646
var self = this;
4747
this.options = options || {};
4848
this.httpPort = options.port || options.port === 0 ? options.port : 8080;
49-
this.httpHost = options.host;
49+
this.httpHost = options.host || 'localhost';
5050
this.timeout = options.timeout || 0;
5151
this.keepAlive = !!options.keepAlive;
5252
this.httpAgent = typeof(options.httpAgent) !== "undefined" ? options.httpAgent : new http.Agent({ keepAlive: this.keepAlive });

0 commit comments

Comments
 (0)