added some API docs for the Socks5 routes

This commit is contained in:
tigerbot 2017-08-04 14:38:22 -06:00
parent 983a6e2cd7
commit 188869b83e
5 changed files with 39 additions and 13 deletions

27
API.md Normal file
View File

@ -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

View File

@ -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)?

View File

@ -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;

View File

@ -274,7 +274,7 @@ module.exports.create = function (deps, config, netHandler) {
);
var wrapped;
// We can't emit the connection to the TLS server until we don't the connection is fully
// We can't emit the connection to the TLS server until we know the connection is fully
// opened, otherwise it might hang open when the decrypted side is destroyed.
// https://github.com/nodejs/node/issues/14605
function emitSock() {