From 3726798062e88afc579cbedfb5ba24e7252ddc6e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 12 Sep 2018 03:33:38 -0600 Subject: [PATCH] update docs --- bin/telebit-remote.js | 44 +--------------------- bin/telebit.js | 35 ++++++++++++----- bin/telebitd.js | 18 ++------- lib/en-us.toml | 87 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 65 deletions(-) create mode 100644 lib/en-us.toml diff --git a/bin/telebit-remote.js b/bin/telebit-remote.js index 521df09..5afe9b2 100755 --- a/bin/telebit-remote.js +++ b/bin/telebit-remote.js @@ -12,6 +12,7 @@ var http = require('http'); //var https = require('https'); var YAML = require('js-yaml'); var TOML = require('toml'); +var TPLS = TOML.parse(fs.readFileSync(path.join(__dirname, "../lib/en-us.toml"), 'utf8')); /* if ('function' !== typeof TOML.stringify) { TOML.stringify = require('json2toml'); @@ -45,48 +46,7 @@ if (-1 !== argIndex) { } function help() { - console.info(''); - console.info('Telebit is a tool for helping you access your devices and share your stuff.'); - console.info(''); - console.info('Usage:'); - console.info(''); - console.info('\ttelebit [flags] '); - console.info(''); - console.info('The flags are:'); - console.info(''); - console.info('\t--config specify a config file (default is ~/.config/telebit/telebit.yml)'); - console.info(''); - console.info('Examples:'); - console.info(''); - //console.info('\tinit bootstrap the config files'); - //console.info(''); - console.info('\tstatus whether enabled or disabled'); - console.info('\tenable disallow incoming connections'); - console.info('\tdisable allow incoming connections'); - console.info(''); - console.info('\tlist list rules for servernames and ports'); - console.info(''); - console.info('\thttp [domain] serve a file, folder, or node express app'); - console.info('\thttp forward all https traffic to port 3000'); - console.info('\thttp none remove all https handlers'); - console.info(''); - console.info('\thttp none example.com remove https handler from example.com'); - console.info('\thttp 3001 sub.example.com forward https traffic for sub.example.com to port 3001'); - console.info('\thttp /module/path sub forward https traffic for sub.example.com to port 3001'); - console.info(''); - console.info('\ttcp none remove all tcp handlers'); - console.info('\ttcp 5050 forward all tcp to port 5050'); - console.info('\ttcp /module/path handle all tcp with a node module'); - console.info(''); - console.info('\ttcp none 6565 remove tcp handler from external port 6565'); - console.info('\ttcp 5050 6565 forward external port 6565 to local 5050'); - console.info('\ttcp /module/path 6565 handle external port 6565 with a node module'); - console.info(''); - console.info('Config:'); - console.info(''); - console.info('\tSee https://git.coolaj86.com/coolaj86/telebit.js'); - console.info(''); - console.info(''); + console.info(TPLS.remote.help.main.replace(/{version}/g, pkg.version)); } var verstr = [ pkg.name + ' remote v' + pkg.version ]; diff --git a/bin/telebit.js b/bin/telebit.js index f278460..21dbc68 100644 --- a/bin/telebit.js +++ b/bin/telebit.js @@ -2,18 +2,35 @@ (function () { 'use strict'; +// // node telebit daemon arg1 arg2 +// if ('daemon' === process.argv[2]) { require('./telebitd.js'); -} else if ('sclient' === process.argv[2]) { - process.argv.splice(1,1); - require('sclient/bin/sclient.js'); -} else if ('ssh' === process.argv[2] && /[\w-]+\.[a-z]{2,}/i.test(process.argv[3])) { - process.argv.splice(1,1,'sclient'); - process.argv.splice(2,1,'--ssh'); - require('sclient/bin/sclient.js'); -} else { - require('./telebit-remote.js'); + return; } +// +// sclient proxies +// +if ('sclient' === process.argv[2]) { + process.argv.splice(1,1); + return; +} +if ('rsync' === process.argv[2]) { + require('sclient/bin/sclient.js'); + return; +} +if ('ssh' === process.argv[2] && /[\w-]+\.[a-z]{2,}/i.test(process.argv[3])) { + process.argv.splice(1,1,'sclient'); + process.argv.splice(2,1,'ssh'); + require('sclient/bin/sclient.js'); + return; +} + +// +// telebit remote +// +require('./telebit-remote.js'); + }()); diff --git a/bin/telebitd.js b/bin/telebitd.js index f5b9c6c..9d3334e 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -17,10 +17,13 @@ var os = require('os'); var fs = require('fs'); var common = require('../lib/cli-common.js'); var http = require('http'); +var TOML = require('toml'); var YAML = require('js-yaml'); var recase = require('recase').create({}); var camelCopy = recase.camelCopy.bind(recase); var snakeCopy = recase.snakeCopy.bind(recase); +var TPLS = TOML.parse(fs.readFileSync(path.join(__dirname, "../lib/en-us.toml"), 'utf8')); + var TelebitRemote = require('../').TelebitRemote; var state = { homedir: os.homedir(), servernames: {}, ports: {}, keepAlive: { state: false } }; @@ -41,20 +44,7 @@ if (-1 !== confIndex) { var cancelUpdater = require('../lib/updater')(pkg); function help() { - console.info(''); - console.info('Telebit Daemon v' + pkg.version); - console.info(''); - console.info('Usage:'); - console.info(''); - console.info('\ttelebitd --config '); - console.info('\tex: telebitd --config ~/.config/telebit/telebitd.yml'); - console.info(''); - console.info(''); - console.info('Config:'); - console.info(''); - console.info('\tSee https://git.coolaj86.com/coolaj86/telebit.js'); - console.info(''); - console.info(''); + console.info(TPLS.daemon.help.main.replace(/{version}/g, pkg.version)); } var verstr = [ pkg.name + ' daemon v' + pkg.version ]; diff --git a/lib/en-us.toml b/lib/en-us.toml new file mode 100644 index 0000000..4e5940c --- /dev/null +++ b/lib/en-us.toml @@ -0,0 +1,87 @@ +[remote] +[remote.help] + +main = "telebit remote v{version} + +Telebit is a tool for helping you access your devices and share your stuff. + +Usage: + + telebit [flags] [arguments] + +The flags are: + + --config specify config file (default is ~/.config/telebit/telebit.yml) + +The commands are: + + status show status and configuration info + enable turn on remote access and sharing + disable turn off remote access and sharing + + http access files, folders, and local apps via https (secure) + ssh (local) enable remote access to this device with ssh-over-https + ssh (remote) access devices via ssh-over-https (telebit, stunnel, openssl, etc) + tcp forward tcp locally + +Use \"telebit help [command]\" for more information about a command. + +Additional help topics: + + config config file format and settings + ssh (proxy) ssh over https and proxy commands + ftp secure ftp file transfer between devices + rsync rsync over https and proxy commands + vpn home network access and private web browsing via socks5 + daemon telebit daemon secure background service + relay telebit secure relay, hosted, and self-hosting options + +Copyright 2015-2018 https://telebit.cloud MPL-2.0 Licensed" + +http = "usage: telebit http [subdomain] + +'telebit http' is the fastest way to share files, folders, and local apps. + + http [subdomain] serve a file, folder, or node express app + ex: telebit http ~/Public pub securely host ~/Public as pub.johndoe.telebit.io + + http [subdomain] forward all https traffic to a local app + ex: telebit http 3000 app publicize localhost:3000 as app.johndoe.telebit.io + + http none [subdomain] remove secure http access for (any or all) subdomain(s) + ex: telebit http none remove all https access +" + +tcp = " +usage: telebit tcp + +'telebit tcp' is provided for seemless connectivity to legacy apps + + tcp [remote] forward tcp to from + ex: telebit tcp 5050 6565 forward tcp port 6565 locally to port 5050 + + tcp [remote] show ftp-style directory listing + ex: telebit tcp ~/Public show listing of ~/Public + + tcp none [remote] disable tcp access for [remote] port + ex: telebit tcp none 6565 remove access to port 6565 + +See also sclient for connecting to legacy apps +with telebit-upscaled secure https access. +" + +[daemon] +[daemon.help] +main = "telebit daemon v{version} + +Usage: + + telebit daemon --config + ex: telebit daemon --config ~/.config/telebit/telebitd.yml + +Additional help topics: + + config config file format and settings + remote telebit cli remote control + +Copyright 2015-2018 https://telebit.cloud MPL-2.0 Licensed"