@@ -3,6 +3,7 @@ const debug = require('debug')('bittorrent-tracker:server')
33const dgram = require ( 'dgram' )
44const EventEmitter = require ( 'events' )
55const http = require ( 'http' )
6+ const https = require ( 'https' )
67const peerid = require ( 'bittorrent-peerid' )
78const series = require ( 'run-series' )
89const string2compact = require ( 'string2compact' )
@@ -59,7 +60,12 @@ class Server extends EventEmitter {
5960
6061 // start an http tracker unless the user explictly says no
6162 if ( opts . http !== false ) {
62- this . http = http . createServer ( )
63+ // Use (ot not) SSL Certificate
64+ if ( typeof ( opts . ssl ) != "undefined" ) {
65+ this . http = https . createServer ( opts . ssl )
66+ } else {
67+ this . http = http . createServer ( )
68+ }
6369 this . http . on ( 'error' , err => { this . _onError ( err ) } )
6470 this . http . on ( 'listening' , onListening )
6571
@@ -95,7 +101,12 @@ class Server extends EventEmitter {
95101 // start a websocket tracker (for WebTorrent) unless the user explicitly says no
96102 if ( opts . ws !== false ) {
97103 if ( ! this . http ) {
98- this . http = http . createServer ( )
104+ // Use (ot not) SSL Certificate
105+ if ( typeof ( opts . ssl ) != "undefined" ) {
106+ this . http = https . createServer ( opts . ssl )
107+ } else {
108+ this . http = http . createServer ( )
109+ }
99110 this . http . on ( 'error' , err => { this . _onError ( err ) } )
100111 this . http . on ( 'listening' , onListening )
101112
@@ -130,7 +141,12 @@ class Server extends EventEmitter {
130141
131142 if ( opts . stats !== false ) {
132143 if ( ! this . http ) {
133- this . http = http . createServer ( )
144+ // Use (ot not) SSL Certificate
145+ if ( typeof ( opts . ssl ) != "undefined" ) {
146+ this . http = https . createServer ( opts . ssl )
147+ } else {
148+ this . http = http . createServer ( )
149+ }
134150 this . http . on ( 'error' , err => { this . _onError ( err ) } )
135151 this . http . on ( 'listening' , onListening )
136152 }
0 commit comments