22
33'use strict' ;
44
5- var colors = require ( 'colors/safe' ) ,
6- os = require ( 'os' ) ,
7- httpServer = require ( '../lib/http-server' ) ,
8- portfinder = require ( 'portfinder' ) ,
9- opener = require ( 'opener' ) ,
10- fs = require ( 'fs' ) ,
11- argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ,
12- qrcode = require ( 'qrcode-terminal' ) ;
5+ var colors = require ( 'colors/safe' ) ,
6+ os = require ( 'os' ) ,
7+ httpServer = require ( '../lib/http-server' ) ,
8+ portfinder = require ( 'portfinder' ) ,
9+ opener = require ( 'opener' ) ,
10+ fs = require ( 'fs' ) ;
11+ var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) , {
12+ alias : {
13+ tls : 'ssl'
14+ }
15+ } ) ;
1316var ifaces = os . networkInterfaces ( ) ;
1417var plainIp ;
1518
@@ -40,7 +43,7 @@ if (argv.h || argv.help) {
4043 ' -U --utc Use UTC time format in log messages.' ,
4144 ' --log-ip Enable logging of the client\'s IP address' ,
4245 '' ,
43- ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com' ,
46+ ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com' ,
4447 ' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false' ,
4548 '' ,
4649 ' --username Username for basic authentication [none]' ,
@@ -64,7 +67,7 @@ if (argv.h || argv.help) {
6467
6568var port = argv . p || argv . port || parseInt ( process . env . PORT , 10 ) ,
6669 host = argv . a || '0.0.0.0' ,
67- ssl = argv . S || argv . ssl ,
70+ tls = argv . S || argv . tls ,
6871 proxy = argv . P || argv . proxy ,
6972 proxyOptions = argv [ 'proxy-options' ] ,
7073 utc = argv . U || argv . utc ,
@@ -160,7 +163,7 @@ function listen(port) {
160163 }
161164 }
162165
163- if ( ssl ) {
166+ if ( tls ) {
164167 options . https = {
165168 cert : argv . C || argv . cert || 'cert.pem' ,
166169 key : argv . K || argv . key || 'key.pem'
@@ -183,24 +186,26 @@ function listen(port) {
183186
184187 var server = httpServer . createServer ( options ) ;
185188 server . listen ( port , host , function ( ) {
186- var protocol = ssl ? 'https://' : 'http://' ;
189+ var protocol = tls ? 'https://' : 'http://' ;
187190
188- logger . info ( [ colors . yellow ( 'Starting up http-server, serving ' ) ,
189- colors . cyan ( server . root ) ,
190- ssl ? ( colors . yellow ( ' through' ) + colors . cyan ( ' https' ) ) : ''
191+ logger . info ( [
192+ colors . yellow ( 'Starting up http-server, serving ' ) ,
193+ colors . cyan ( server . root ) ,
194+ tls ? ( colors . yellow ( ' through' ) + colors . cyan ( ' https' ) ) : ''
191195 ] . join ( '' ) ) ;
192196
193197 logger . info ( [ colors . yellow ( '\nhttp-server version: ' ) , colors . cyan ( require ( '../package.json' ) . version ) ] . join ( '' ) ) ;
194198
195- logger . info ( [ colors . yellow ( '\nhttp-server settings: ' ) ,
196- ( [ colors . yellow ( 'CORS: ' ) , argv . cors ? colors . cyan ( argv . cors ) : colors . red ( 'disabled' ) ] . join ( '' ) ) ,
197- ( [ colors . yellow ( 'Cache: ' ) , argv . c ? ( argv . c === '-1' ? colors . red ( 'disabled' ) : colors . cyan ( argv . c + ' seconds' ) ) : colors . cyan ( '3600 seconds' ) ] . join ( '' ) ) ,
198- ( [ colors . yellow ( 'Connection Timeout: ' ) , argv . t === '0' ? colors . red ( 'disabled' ) : ( argv . t ? colors . cyan ( argv . t + ' seconds' ) : colors . cyan ( '120 seconds' ) ) ] . join ( '' ) ) ,
199- ( [ colors . yellow ( 'Directory Listings: ' ) , argv . d ? colors . red ( 'not visible' ) : colors . cyan ( 'visible' ) ] . join ( '' ) ) ,
200- ( [ colors . yellow ( 'AutoIndex: ' ) , argv . i ? colors . red ( 'not visible' ) : colors . cyan ( 'visible' ) ] . join ( '' ) ) ,
201- ( [ colors . yellow ( 'Serve GZIP Files: ' ) , argv . g || argv . gzip ? colors . cyan ( 'true' ) : colors . red ( 'false' ) ] . join ( '' ) ) ,
202- ( [ colors . yellow ( 'Serve Brotli Files: ' ) , argv . b || argv . brotli ? colors . cyan ( 'true' ) : colors . red ( 'false' ) ] . join ( '' ) ) ,
203- ( [ colors . yellow ( 'Default File Extension: ' ) , argv . e ? colors . cyan ( argv . e ) : ( argv . ext ? colors . cyan ( argv . ext ) : colors . red ( 'none' ) ) ] . join ( '' ) )
199+ logger . info ( [
200+ colors . yellow ( '\nhttp-server settings: ' ) ,
201+ ( [ colors . yellow ( 'CORS: ' ) , argv . cors ? colors . cyan ( argv . cors ) : colors . red ( 'disabled' ) ] . join ( '' ) ) ,
202+ ( [ colors . yellow ( 'Cache: ' ) , argv . c ? ( argv . c === '-1' ? colors . red ( 'disabled' ) : colors . cyan ( argv . c + ' seconds' ) ) : colors . cyan ( '3600 seconds' ) ] . join ( '' ) ) ,
203+ ( [ colors . yellow ( 'Connection Timeout: ' ) , argv . t === '0' ? colors . red ( 'disabled' ) : ( argv . t ? colors . cyan ( argv . t + ' seconds' ) : colors . cyan ( '120 seconds' ) ) ] . join ( '' ) ) ,
204+ ( [ colors . yellow ( 'Directory Listings: ' ) , argv . d ? colors . red ( 'not visible' ) : colors . cyan ( 'visible' ) ] . join ( '' ) ) ,
205+ ( [ colors . yellow ( 'AutoIndex: ' ) , argv . i ? colors . red ( 'not visible' ) : colors . cyan ( 'visible' ) ] . join ( '' ) ) ,
206+ ( [ colors . yellow ( 'Serve GZIP Files: ' ) , argv . g || argv . gzip ? colors . cyan ( 'true' ) : colors . red ( 'false' ) ] . join ( '' ) ) ,
207+ ( [ colors . yellow ( 'Serve Brotli Files: ' ) , argv . b || argv . brotli ? colors . cyan ( 'true' ) : colors . red ( 'false' ) ] . join ( '' ) ) ,
208+ ( [ colors . yellow ( 'Default File Extension: ' ) , argv . e ? colors . cyan ( argv . e ) : ( argv . ext ? colors . cyan ( argv . ext ) : colors . red ( 'none' ) ) ] . join ( '' ) )
204209 ] . join ( '\n' ) ) ;
205210
206211 logger . info ( colors . yellow ( '\nAvailable on:' ) ) ;
0 commit comments