Permalink
Browse files

allow the cli tool to be used with tls

  • Loading branch information...
1 parent 31e425d commit 3b1aebe36f4a765cc284b37c05975cd0c9873c86 Nate Silva committed Aug 20, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 bin/bouncy.js
View
@@ -1,17 +1,25 @@
#!/usr/bin/env node
var configFile = process.argv[2];
var port = parseInt(process.argv[3], 10);
+var key = process.argv[4];
+var cert = process.argv[5];
if (!configFile || !port) {
- console.error('Usage: bouncy [routes.json] [port]');
+ console.error('Usage: bouncy [routes.json] [port] [keyfile] [certfile]');
process.exit(1);
}
var fs = require('fs');
var config = JSON.parse(fs.readFileSync(configFile));
+var opts = {};
+if (key && cert) {
+ opts.key = fs.readFileSync(key);
+ opts.cert = fs.readFileSync(cert);
+}
+
var bouncy = require('bouncy');
-bouncy(function (req, bounce) {
+bouncy(opts, function (req, bounce) {
var host = (req.headers.host || '').replace(/:\d+$/, '');
var route = config[host] || config[''];

0 comments on commit 3b1aebe

Please sign in to comment.