Beispiel #1
0
        server: (function () {
            if (options.get('scheme') === 'https') {
                const pfxPath = options.getIn(['https', 'pfx']);

                if (pfxPath) {
                    return https.createServer(getPFX(pfxPath), app);
                }

                return https.createServer(getKeyAndCert(options), app);
            }
            return http.createServer(app);
        })(),
 _startAuthenticationServer():Promise {
   var result = deferred();
   
   var port = config.controlChannelPort + 1;
   var serverOptions = {
     key: keys.privateKey,
     cert: keys.certificate
   };
   https.createServer(serverOptions, (req, res) => {
     var path = this._pathForRequest(req);
     console.log("Path:", path);
     if (path.indexOf('authenticate') === 0) {
       return this._authenticate(req, res);
     }
   }).listen(port, function(err) {
     if (err) {
       result.reject('Unable to start control channel server: ' +  err);
     } else {
       console.log('Listening for authentication requests on port', port);
       result.resolve();
     }
   });
   
   return result.promise;
 }
Beispiel #3
0
export function start(
  port,
  networkInterface,
  ssl,
  _listener,
  onConnection?
): void {
  listener = _listener;

  if (ssl) {
    const options = {
      key: fs.readFileSync(ssl.key),
      cert: fs.readFileSync(ssl.cert),
      ca: null
    };

    try {
      // Use intermediate certificates if available
      options.ca = fs
        .readFileSync(ssl.ca)
        .toString()
        .match(/-+BEGIN CERTIFICATE-+[0-9a-zA-Z+\-/=\s]+?-+END CERTIFICATE-+/g);
    } catch (error) {
      // No intermediate certificate
    }
    server = https.createServer(options, listener);
    if (onConnection != null) server.on("secureConnection", onConnection);
  } else {
    server = http.createServer(listener);
    if (onConnection != null) server.on("connection", onConnection);
  }

  server.listen(port, networkInterface);
}
Beispiel #4
0
function startServer(webServerConfig: IWebServerConfig, app: core.Express, done:(secure: boolean, host:string, port:number) => void, errorCallback?:(err:any) => void ) : void {
	let server: net.Server = null;
	let wsConfig: IHTTPServerConfig = null;
	if (webServerConfig.https) {
		wsConfig = webServerConfig.https;
		let httpsConfig = webServerConfig.https;
		let sslConfig = httpsConfig.ssl;
		let private_key_file = sslConfig.private_key_file;
		let certificate_file = sslConfig.certificate_file;
		let ca_files = sslConfig.ca_files;
		let privateKey  = fs.readFileSync(private_key_file, 'utf8');
		let certificate = fs.readFileSync(certificate_file, 'utf8');
		let credentials:https.ServerOptions = {key: privateKey, cert: certificate};
		if (ca_files && ca_files.length > 0) {
			let ca:string[] = [];
			for (let i in ca_files)
				ca.push(fs.readFileSync(ca_files[i], 'utf8'));
			credentials.ca = ca;
		}
		server = https.createServer(credentials, app);
	} else {
		wsConfig = webServerConfig.http;
		server = http.createServer(app);
	}
	let port = (wsConfig.port ? wsConfig.port : (webServerConfig.https ? 443 : 80));
	let host = (wsConfig.host ? wsConfig.host : "0.0.0.0");	
	server.on('error', (err:any) => {
		if (typeof errorCallback === 'function') errorCallback(err);
	});
	server.listen(port, host, () => {
		let host = server.address().address;
		let port = server.address().port;
		if (typeof done === 'function') done((webServerConfig.https ? true : false), host, port);
	});
}
Beispiel #5
0
export async function createHttpServer(devServerConfig: d.DevServerConfig, fs: d.FileSystem, destroys: d.DevServerDestroy[]) {
  // figure out the port to be listening on
  // by figuring out the first one available
  devServerConfig.port = await findClosestOpenPort(devServerConfig.address, devServerConfig.port);

  // create our request handler
  const reqHandler = createRequestHandler(devServerConfig, fs);

  let server: http.Server;

  if (devServerConfig.protocol === 'https') {
    // https server
    server = https.createServer(await getSSL(), reqHandler) as any;

  } else {
    // http server
    server = http.createServer(reqHandler);
  }

  destroys.push(() => {
    // close down the serve on destroy
    server.close();
    server = null;
  });

  return server;
}
 _startControlChannelServer():Promise {
   var result = deferred();
   
   var port = config.controlChannelPort;
   var serverOptions = {
     key: keys.privateKey,
     cert: keys.certificate,
     ca: [keys.certificate],
     requestCert: true,
     rejectUnauthorized: true
   };
   https.createServer(serverOptions, (req, res) => {
     var path = this._pathForRequest(req);
     console.log(req.connection.getPeerCertificate());
     console.log(req.secure);
     console.log(req.client.authorized);
   }).listen(port, function(err) {
     if (err) {
       result.reject('Unable to start control channel server: ' +  err);
     } else {
       console.log('Listening for control channel traffic on port', port);
       result.resolve();
     }
   });
   
   return result.promise;
 }
Beispiel #7
0
function createSimpleServer({ port = 8000 }) {
    const server = createServer({ key: privateKey, cert: certificate });
    server.addListener('request', request);
    server.listen(port);
    console.log(`Listen port ${port}, for simple server`);
    console.log(`https://${ip}:${port}`);
}
Beispiel #8
0
  async run(inputs: CommandLineInputs, options: CommandLineOptions) {
    const [ url ] = inputs;
    const { host, port, ssl } = options;

    const protocol = ssl ? 'https' : 'http';
    const projectType = options['project-type'];
    const name = options['app-name'];
    const version = options['app-version'];

    const app = express();

    app.use('/', express.static(WWW_DIRECTORY));

    app.get('/api/app', (req, res) => {
      res.json({ url, name, version, projectType });
    });

    const server = ssl ? https.createServer(await this.collectSecureContextOptions(options), app) : http.createServer(app);
    server.listen({ port, host });

    const labUrl = `${protocol}://${host}:${port}`;

    server.on('listening', () => {
      process.stdout.write(
        'Ionic Lab running!\n' +
        `Lab: ${chalk.bold(labUrl)}\n` +
        `App: ${chalk.bold(url)}\n`
      );
    });
  }
Beispiel #9
0
  before((done) => {
    const options = {
      key: fs.readFileSync(path.join(certPath, 'server.key')),
      cert: fs.readFileSync(path.join(certPath, 'server.pem')),
      ca: [
        fs.readFileSync(path.join(certPath, 'rootCA.pem')),
        fs.readFileSync(path.join(certPath, 'intermediateCA.pem'))
      ],
      requestCert: true,
      rejectUnauthorized: false
    }

    server = https.createServer(options, (req, res) => {
      if ((req as any).client.authorized) {
        res.writeHead(200)
        res.end('<title>authorized</title>')
      } else {
        res.writeHead(401)
        res.end('<title>denied</title>')
      }
    })

    server.listen(0, '127.0.0.1', () => {
      const port = (server.address() as net.AddressInfo).port
      secureUrl = `https://127.0.0.1:${port}`
      done()
    })
  })
Beispiel #10
0
  return co(function *createHttpsServer() {
    const privateKeyPromise = fs.readFileAsync(keypath, 'utf8');
    const certificatePromise = fs.readFileAsync(crtpath, 'utf8');

    const [key, cert] = yield Promise.all([privateKeyPromise, certificatePromise]);

    return https.createServer({ secureOptions: SSL_OP_NO_TLSv1, key, cert }, app);
  }).call(this);
Beispiel #11
0
function startWithPort(userOptions: ServerOptions) {
  let options = applyDefaultOptions(userOptions);
  let protocol = getProtocol(options);
  let app = getApp(options);
  let server = protocol === 'http' ? http.createServer(app) : https.createServer(app);
  let serverStartedResolve: (r: any) => void;
  let serverStartedReject: (r: any) => void;
  let serverStartedPromise = new Promise((resolve, reject) => {
    serverStartedResolve = resolve;
    serverStartedReject = reject;
  });

  server = app.listen(options.port, options.hostname,
      () => serverStartedResolve(server));

  server.on('error', function(err: any) {
    if (err.code === 'EADDRINUSE') {
      console.error(portInUseMessage(options.port));
    }
    serverStartedReject(err);
  });

  let serverUrl = {
    protocol: protocol,
    hostname: options.hostname,
    port: `${options.port}`,
  };
  let componentUrl: url.Url = Object.assign({}, serverUrl);
  componentUrl.pathname = `components/${options.packageName}/`;

  console.log(`Files in this directory are available under the following URLs
    applications: ${url.format(serverUrl)}
    reusable components: ${url.format(componentUrl)}`);

  if (options.open) {
    let openUrl: url.Url;
    if (options.openPath) {
      openUrl = Object.assign({}, serverUrl);
      openUrl.pathname = options.openPath;
    } else {
      openUrl = Object.assign({}, componentUrl);
    }
    if (!Array.isArray(options.browser)) {
      openWebPage(url.format(openUrl));
    } else {
      options.browser.forEach((browser) => {
        openWebPage(url.format(openUrl), browser);
      });
    }
  }

  return serverStartedPromise;
}
 static run (app: express.Application): void {
   const port = ApplicationRunner.applicationPort()
   if (app.locals.ENV === 'development' || app.locals.ENV === 'dockertests') {
     const server = https.createServer(ApplicationRunner.getSSLOptions(), app)
     server.listen(port, () => {
       logger.info(`Listener started (PID ${process.pid}): https://localhost:${port}`)
     })
   } else {
     app.listen(port, () => {
       logger.info(`Listener started (PID ${process.pid}): http://localhost:${port}`)
     })
   }
 }
Beispiel #13
0
    return getPort().then(port => {
        const s = https.createServer(opts, (req, resp) => s.emit(req.url, req, resp));

        s.host = host;
        s.port = port;
        s.url = `https://${host}:${port}`;
        s.protocol = 'https';

        s.listen = pify(s.listen, Promise);
        s.close = pify(s.close, Promise);

        return s;
    });
Beispiel #14
0
    /**
	 * Initializes the comms controller
	 */
    async initialize( db: mongodb.Db ): Promise<void> {
        let cfg = this._cfg;

        // Throw error if no socket api key
        if ( !cfg.websocket.socketApiKey )
            throw new Error( 'The socketApiKey was not set in the config file. Make sure it exists (Check the example-config.json) ' );

        this._hashedApiKey = bcrypt.hashSync( cfg.websocket.socketApiKey, 10 );

        // dummy request processing - this is not actually called as its handed off to the socket api
        const processRequest = function( req, res ) {
            req; // Suppress compiler warning
            res.writeHead( 200 );
            res.end( 'All glory to WebSockets!\n' );
        };

        // Create the web socket server
        if ( cfg.websocket.ssl ) {
            info( 'Creating secure socket connection' );
            let httpsServer: https.Server;
            const caChain = [ fs.readFileSync( cfg.websocket.ssl.intermediate ), fs.readFileSync( cfg.websocket.ssl.root ) ];
            const privkey = cfg.websocket.ssl.key ? fs.readFileSync( cfg.websocket.ssl.key ) : null;
            const theCert = cfg.websocket.ssl.cert ? fs.readFileSync( cfg.websocket.ssl.cert ) : null;

            info( `Attempting to start Websocket server with SSL...` );
            httpsServer = https.createServer( { key: privkey, cert: theCert, passphrase: cfg.websocket.ssl.passPhrase, ca: caChain }, processRequest );
            httpsServer.listen( cfg.websocket.port );
            this._server = new ws.Server( { host: cfg.websocket.host, server: httpsServer } );
        }
        else {
            info( 'Creating regular socket connection' );
            this._server = new ws.Server( { host: cfg.websocket.host, port: cfg.websocket.port } );
        }

        info( 'Websockets attempting to listen on HTTP port ' + this._cfg.websocket.port );

        // Handle errors
        this._server.on( 'error', ( err ) => {
            logError( 'Websocket error: ' + err.toString() );
            this._server.close();
        } );

        // A client has connected to the server
        this._server.on( 'connection', ( ws: ws ) => {
            this.onWsConnection( ws );
        } );

        // Setup the socket API
        new SocketAPI( this );
    }
    /**
     * Create a socket.io server.
     *
     * @return {any}
     */
    httpServer(secure: boolean) {
        this.express = express();

        if (secure) {
            var httpServer = https.createServer(this.options, this.express);
        } else {
            var httpServer = http.createServer(this.express);
        }

        httpServer.listen(this.getPort(), this.options.host);

        this.authorizeRequests();

        return this.io = io(httpServer, this.options.socketio);
    }
 start() {
   var port = config.controlChannelPort;
   var result = deferred();
   https.createServer({key: keys.privateKey, cert: keys.certificate}, function(req, res){
      res.end("o hai!")
   }).listen(port, function(err) {
     if (err) {
       result.reject('Unable to start control channel server: ', err);
     } else {
       console.log('Control channel listening on port', port);
       result.resolve();
     }
   });
   return result.promise;
 }
Beispiel #17
0
  listen(...args: any[]) {
    let options = this.options,
      instance = this;

    // set up a http server and pass in the listener
    if (options.ssl) {
      instance.server = https.createServer(
        options.ssl,
        httpListener.bind(instance)
      );
    } else {
      instance.server = http.createServer(httpListener.bind(instance));
    }
    instance.server.listen(...args);
    return instance.server;
  }
Beispiel #18
0
function getServer(): any {
    if (config.get("protocol") === "https" ) {
        let certificate = fs.readFileSync(config.get("ssl_cert") as string);
        let privateKey = fs.readFileSync(config.get("ssl_key") as string);
        console.log("creating https server");
        let server = https.createServer({key: privateKey, cert: certificate}, app);
        server.setTimeout(0);
        return server;
    }
    else {
        console.log("creating http server");
        let server = http.createServer(app);
        server.setTimeout(0);
        return server;
    }
}
createConnection(ormOptions).then(async connection => {
  /**
   * Listen on provided port, on all network interfaces.
   */
  if (config.app.httpServer === 'enabled') {
    httpServer.listen(config.app.port);
  }

  if (config.app.httpsServer === 'enabled') {
    const httpsOptions = {
      key: fs.readFileSync(__dirname + '/../certs/ico-key.pem'),
      cert: fs.readFileSync(__dirname + '/../certs/ico-crt.pem'),
      ca: fs.readFileSync(__dirname + '/../certs/cloudflare.ca'),
      requestCert: true,
      rejectUnauthorized: false
    };
    const httpsServer = https.createServer(httpsOptions, app);
    httpsServer.listen(config.app.httpsPort);
  }
}).catch(error => console.log('TypeORM connection error: ', error));
Beispiel #20
0
function createServer(spec: spec) {
  if (server) {
    server.destroy();
  }

  app = express();
  let protocol = "http";

  if (spec.server.certificatePath && spec.server.keyPath) {
    const options = {
      key: fs.readFileSync(spec.server.keyPath),
      cert: fs.readFileSync(spec.server.certificatePath),
      requestCert: false,
      rejectUnauthorized: false
    };
    server = https.createServer(options, app);
    protocol = "https";
  } else {
    server = http.createServer(app);
  }
  enableDestroy(server);

  app.use(bodyParser());
  app.use(bodyParser.urlencoded({ extended: true }));

  if (spec.server.staticFolder) {
    app.use(express.static(spec.server.staticFolder));
  }

  server.listen(spec.server.port, () => {
    console.log(`http://localhost:${spec.server.port}`);
  });

  updateRoutes(app, spec.endpoints);

  return {
    protocol,
    server,
    app
  };
}
    static getCommunicator(meshi: Meshinator, type: CommunicatorType[]): Communicator {
        //サーバ作成
        const app = express();
        app.use(bodyParser.json());
        app.use(bodyParser.urlencoded({ extended: true }));
        const options = {
            key: fs.readFileSync(process.env.npm_package_config_rsa),
            cert: fs.readFileSync(process.env.npm_package_config_crt)
        };

        const comm = new Communicator(meshi);
        const receiver = this.createReceiver(comm, type, app);
        comm.setReceiver(receiver);

        //サーバ起動
        https.createServer(options,app).listen(443);

        return comm;


    }
Beispiel #22
0
 .then(() => {
     configureExpress(app);
     configurePassport();
     configureRoutes(app);        
     // node dist/server/server.js --SECURED 
     // if you need run locally in https mode
     if (nconf.get("SECURED")) {
         const privateKey = fs.readFileSync(path.join(__dirname, './config/ssl/testkey.pem'), 'utf8');
         const certificate = fs.readFileSync(path.join(__dirname, './config/ssl/testcert.pem'), 'utf8');
         const httpsPort = nconf.get("httpsPort") || 443;
         const httpsServer = https.createServer({
             key: privateKey,
             cert: certificate
         }, app);
         httpsServer.listen(httpsPort);
         console.info(chalk.green(`Server started on https port:  ${httpsPort}`));
     } else {            
         let httpPort = nconf.get("httpPort") || 3000;
         app.listen(httpPort);
         console.info(chalk.green(`Server started on http port:  ${httpPort}`));
     }
 })
export function expressInit(port: number, routerPath: string, initRouter: () => express.Router, thisArg: any = this, conf: SSLConfig = undefined): express.Express {
  let app = express();
  // NOTE: In `limit` value, `mb` must be lowercase!
  app.use(bodyParser.json({
    limit: "50mb",
    parameterLimit: 50000
  }));
  app.use(bodyParser.urlencoded({
    extended: true,
    limit: "50mb",
    parameterLimit: 50000
  }));
  app.use(routerPath, initRouter.call(thisArg));
  if (conf && typeof conf.key === "string" && typeof conf.cert === "string") {
    // Create a https server with passed `conf` an listen on `port`.
    https.createServer(conf, app).listen(port);
  }
  else {
    // Config not passed, assuming https is not required, use regular http.
    app.listen(port);
  }
  console.log(`Router listening on ${port}`);
  return app;
}
Beispiel #24
0
app.get('/favicon.ico', (req, res) => {
	res.sendFile(path.resolve(`${__dirname}/favicon.ico`));
});

// Return publicconfig
app.get('/publicconfig.json', (req, res) => {
	res.send(config.publicConfig);
});

router(app);

let server: http.Server | https.Server;

if (config.https.enable) {
	server = https.createServer({
		key: fs.readFileSync(config.https.keyPath),
		cert: fs.readFileSync(config.https.certPath)
	}, app);

	http.createServer((req, res) => {
		res.writeHead(301, {
			Location: config.publicConfig.url + req.url
		});
		res.end();
	}).listen(config.port.http);
} else {
	server = http.createServer(app);
}

// go stream
streaming(server);
app.set('views', __dirname + '/views');

// load UX and API controllers
log('initialize controllers');
let controllers: Controllers = new Controllers(app);
controllers.init();

// setup ssl self hosting (use the same certs from browsersync)
let httpsOptions: https.ServerOptions = {
  cert: fs.readFileSync(__dirname + '/../../node_modules/browser-sync/lib/server/certs/server.crt'),
  key: fs.readFileSync(__dirname + '/../../node_modules/browser-sync/lib/server/certs/server.key')
};
let httpServerPort: number = process.env.PORT || 3433;  // use server value (for Azure) or local port

// create & startup HTTPS webserver
https.createServer(httpsOptions, app)
     .listen(httpServerPort);

console.log(colors.cyan('+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+'));
console.log(colors.green('Starting up https server...'));
console.log(colors.green('Available on:'));

// list IPs listening on
let networks: { [index: string]: os.NetworkInterfaceInfo[] } = os.networkInterfaces();
Object.keys(networks).forEach((device: string) => {
  networks[device].forEach((details: os.NetworkInterfaceInfo) => {
    if (details.family === 'IPv4') {
      console.log(colors.yellow('  https://' + details.address + ':' + httpServerPort));
    }
  });
});
Beispiel #26
0
	opts.createServer = function (listener): http.Server | https.Server {
		if (typeof listener !== 'function') throw new TypeError("bad listener parameter: " + typeof listener);
		return opts.secure ? https.createServer(opts, listener) : http.createServer(listener);
	};
Beispiel #27
0
        res.redirect('/login');
    }
};
app.use(express.static(__dirname + '/public'));
app.use('/exam_images', express.static(c.image_dir));
app.use('/figures', express.static(c.figure_dir));

// development only
if ('development' == app.get('env')) {
    app.use(errorhandler());
}

app.get("/", sessionCheck, routes.index);
app.post("/", index_post.index);
app.get("/login", login.index);
app.post('/login', login_post.index);
app.get("/logout", logout.index);
app.get("/result/:exam_id", result.index);
app.get("/images", images.index);
app.get("/image_folder", image_folder.index);
app.get("/search", search.index);
app.post("/search", search_post.index);

process.on('uncaughtException', function(err) {
    console.log(err);
});

https.createServer(options, app).listen(app.get('port'), function() {
    console.log('Express server listening on port ' + app.get('port'));
});
Beispiel #28
0
        class MyServerResponse extends http.ServerResponse {
            foo: string;
        }

        let server: https.Server;

        server = new https.Server();
        server = new https.Server(reqListener);
        server = new https.Server({ IncomingMessage: MyIncomingMessage});

        server = new https.Server({
            IncomingMessage: MyIncomingMessage,
            ServerResponse: MyServerResponse
        }, reqListener);

        server = https.createServer();
        server = https.createServer(reqListener);
        server = https.createServer({ IncomingMessage: MyIncomingMessage });
        server = https.createServer({ ServerResponse: MyServerResponse }, reqListener);

        const timeout: number = server.timeout;
        const listening: boolean = server.listening;
        const keepAliveTimeout: number = server.keepAliveTimeout;
        const maxHeadersCount: number | null = server.maxHeadersCount;
        const headersTimeout: number = server.headersTimeout;
        server.setTimeout().setTimeout(1000).setTimeout(() => {}).setTimeout(100, () => {});
    }
}

////////////////////////////////////////////////////
/// string_decoder tests : https://nodejs.org/api/string_decoder.html
Beispiel #29
0
async function starter(cfg: Config): Promise<void> {
  const redirectHttp = express();
  redirectHttp.get('/*', (req, res, next) =>
    res.redirect(`https://${cfg.domain}/`)
  );
  redirectHttp.listen(cfg.redirectPort);
  console.log(`Started redirectPort on ${cfg.redirectPort}`);

  let httpServer: https.Server | http.Server;
  if (cfg.credentials.privateKey) {
    httpServer = https.createServer({
      key: cfg.credentials.privateKey,
      cert: cfg.credentials.certificate
    });
    console.log(`Listen on: https ${cfg.applicationPort}`);
  } else {
    httpServer = http.createServer();
    console.log(`Listen on: http ${cfg.applicationPort}`);
  }

  const app = express();
  app.use(express.static(path.join(process.cwd(), 'dist')));

  let gpg = await Gpg.create();
  if (cfg.useMock) {
    const cmd: string[] = gpg.mockCmd;
    const cmdAgent = cmd.concat(['connect-agent']);
    gpg = gpg.setGpgCmd(cmd);
    gpg = gpg.setGpgAgentCmd(cmdAgent);
  }
  const gi = await gpg.info();
  console.log('Created Gpg:', gi);

  const observer = Observer.start(gpg);
  const dispatch = Dispatch.start(gpg);

  app.get('/', (req: express.Request, res: express.Response) =>
    res.redirect('/index.html')
  );

  app.get('/privkey.pem', (req: express.Request, res: express.Response) => {
    if (cfg.credentials.privateKey) {
      res.send(cfg.credentials.privateKey);
    } else {
      res.sendStatus(404);
    }
  });
  app.get('/fullchain.pem', (req: express.Request, res: express.Response) => {
    if (cfg.credentials.certificate) {
      res.send(cfg.credentials.certificate);
    } else {
      res.sendStatus(404);
    }
  });

  let wss = new ws.Server({ server: httpServer });
  wss.on('connection', sock => {
    // var location = url.parse(ws.upgradeReq.url, true);
    // you might use location.query.access_token to authenticate or share sessions
    // or ws.upgradeReq.headers.cookie (see http://stackoverflow.com/a/16395220/151312)
    // ws.send('something');
    console.log('WS-Connect');
    observer.register(sock);
    sock.on('close', () => {
      console.log('close');
      observer.unregister(sock);
    });
    // ws.on('data', msg:any => console.log(msg));
    sock.on('message', payload => {
      let msg = Message.fromData(payload.toString());
      // console.log('onMessage')
      dispatch.run(observer, sock, msg);
    });
  });

  httpServer.on('request', app);
  httpServer.listen(cfg.applicationPort);
}
Beispiel #30
0
        origin: 'http://websocket.org'
    });

    wsc.on('open',  () => wsc.send(Date.now().toString(), {mask: true}));
    wsc.on('close', () => console.log('disconnected'));

    wsc.on('message', (data, flags) => {
        console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags);
        setTimeout(() => {
            wsc.send(Date.now().toString(), {mask: true});
        }, 500);
    });
}

{
    new WebSocket.Server({ server: https.createServer({}) });
    new WebSocket.Server({ server: http.createServer() });
}


{
    const verifyClient = function(
      info: {
        origin: string
        secure: boolean
        req: http.IncomingMessage
      }
      , callback: (res: boolean) => void
    ): void {
        callback(true)
    }