From 188869b83e3f6d901ee2cd7be35899d867132ad6 Mon Sep 17 00:00:00 2001 From: tigerbot Date: Fri, 4 Aug 2017 14:38:22 -0600 Subject: [PATCH] added some API docs for the Socks5 routes --- API.md | 27 +++++++++++++++++++++++++++ README.md | 11 +++-------- lib/app.js | 8 ++++++-- lib/modules/http.js | 4 ++-- lib/modules/tls.js | 2 +- 5 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 API.md diff --git a/API.md b/API.md new file mode 100644 index 0000000..57e3ae1 --- /dev/null +++ b/API.md @@ -0,0 +1,27 @@ +# API +The API system is intended for use with Desktop and Mobile clients. +It must be accessed using one of the following domains as the Host header: + +``` +admin.invalid +localhost.admin.daplie.me +``` + +## Socks5 Proxy + +### Check Status + * **URL** `/api/goldillocks@daplie.com/socks5` + * **Method** `GET` + * **Response**: The returned object will have up to two values inside + * `running`: boolean value to indicate if the proxy is currently active + * `port`: if the proxy is running this is the port it's running on + +### Start Proxy + * **URL** `/api/goldillocks@daplie.com/socks5` + * **Method** `POST` + * **Response**: Same response as for the `GET` resquest + +### Stop Proxy + * **URL** `/api/goldillocks@daplie.com/socks5` + * **Method** `DELETE` + * **Response**: Same response as for the `GET` resquest diff --git a/README.md b/README.md index f3b8474..53d0fee 100644 --- a/README.md +++ b/README.md @@ -336,7 +336,8 @@ It has the following options: secret A 128-bit or greater string to use for signing tokens (HMAC JWT) ex: abc123 -servernames An array of string servernames that should be captured as the tunnel server, ignoring the TLS forward module +servernames An array of string servernames that should be captured as the + tunnel server, ignoring the TLS forward module ex: api.tunnel.example.com ``` @@ -399,13 +400,7 @@ mdig _cloud._tcp.local ### api -The API system is intended for use with Desktop and Mobile clients. -It must be accessed using one of the following domains as the Host header: - -``` -admin.invalid -localhost.admin.daplie.me -``` +See [API.md](/API.md) @tigerbot: How are the APIs used (in terms of URL, Method, Headers, etc)? diff --git a/lib/app.js b/lib/app.js index 3639036..f633712 100644 --- a/lib/app.js +++ b/lib/app.js @@ -114,7 +114,7 @@ module.exports = function (myDeps, conf, overrideHttp) { path.modules.forEach(mapMap); }); - return app.use('/api/com.daplie.goldilocks/:name', function (req, res, next) { + function _goldApis(req, res, next) { if (!goldilocksApis) { goldilocksApis = createGoldilocksApis(); } @@ -124,7 +124,11 @@ module.exports = function (myDeps, conf, overrideHttp) { } else { next(); } - }).use('/', function (req, res, next) { + } + return app + .use('/api/com.daplie.goldilocks/:name', _goldApis) + .use('/api/goldilocks@daplie.com/:name', _goldApis) + .use('/', function (req, res, next) { if (!req.headers.host) { next(new Error('missing HTTP Host header')); return; diff --git a/lib/modules/http.js b/lib/modules/http.js index 63cd2e6..303f195 100644 --- a/lib/modules/http.js +++ b/lib/modules/http.js @@ -446,8 +446,8 @@ module.exports.create = function (deps, conf, greenlockMiddleware) { prom.then(function (handled) { // XXX TODO SECURITY html escape - var host = (headers.host || '[no host header]').replace(/