-const argv = require('minimist')(process.argv.slice(2), {
- string: [ 'ca-cert', 'ca-key', 'config', 'client-js', 'host-js', 'electron', 'port' ],
- boolean: [ 'remote-host' ],
- alias: { c: 'config',
- j: 'client-js',
- J: 'host-js',
- C: 'ca-cert',
- K: 'ca-key',
- e: 'electron',
- r: 'remote-host',
- p: 'port'
- },
- default: { config: undefined,
- 'client-js': 'client.js',
- 'host-js': 'host.js',
- 'ca-cert': 'stunnel.cert',
- 'ca-key': 'stunnel.key',
- 'remote-host': true,
- 'port': 2443
- },
- stopEarly: true,
- unknown: (opt) => {
- console.log(process.argv.join(" ") + '\nUnknown operator: ' + opt + `
-Usage: strapp [OPTION]...
-Route https connections from a hardware port to a remote host, and initiate
-peer-to-peer connection with clients.
-
-CONFIG
- -c, --config=path Configuration file to use (/etc/strapp.conf)
- - overridden by command line opts
- -j, --client-js=path Path to the client Strapp code (./strapp-client.js)
- -J, --host-js=path Path to the host Strapp code (./strapp-host.js)
- -C, --ca-cert=path Accessible location of the CA Cert (./stunnel.cert)
- -K, --ca-key=path Accessible location of the CA Key (./stunnel.key)
- -p, --port=number The local port to bind HTTPS listener to (2443)
-
-ROUTING
- -e, --electron=route Route to the local electron user (nil)
- - enables optional electron dependency
- -d, --dedicated=route Route all incoming connections to this route (nil)
- - used in conjunction with '-e=my_route'
-
-(c)2017 jk software
-`)
- process.exit()
+/* const routeConnection = (request,response) => {
+ const htArgv = request.url.slice(1).split("?")
+ let routeName = /[^\/]*/.match(htArgv[0])[0]
+ if (routeName === '')
+ routeName = opts['index']
+ if (routeName.indexOf('.') != -1) {
+ if (routeName in fileBuf) {
+ response.writeHead(200, { 'Content-Type': fileBuf[routeName].mime })
+ response.write(fileBuf[routeName].data)
+ }
+ else {
+ if ('404.html' in fileBuf) {
+ response.writeHead(404, fileBuf['404.html'].mime)
+ response.write(fileBuf['404.html'].data)
+ }
+ else
+ response.writeHead(404)
+ }
+ response.end()