mirror of
https://github.com/bitinflow/server.git
synced 2026-03-13 13:35:53 +00:00
add /api/tunnels/:id/status endpoint
Provides connected_sockets information for a tunnel.
This commit is contained in:
@@ -12,6 +12,10 @@ class Client {
|
||||
this.debug = Debug('lt:Client');
|
||||
}
|
||||
|
||||
stats() {
|
||||
return this.agent.stats();
|
||||
}
|
||||
|
||||
handleRequest(req, res) {
|
||||
this.debug('> %s', req.url);
|
||||
const opt = {
|
||||
|
||||
@@ -39,6 +39,12 @@ class TunnelAgent extends Agent {
|
||||
this.closed = false;
|
||||
}
|
||||
|
||||
stats() {
|
||||
return {
|
||||
connectedSockets: this.connectedSockets,
|
||||
};
|
||||
}
|
||||
|
||||
listen() {
|
||||
const server = this.server;
|
||||
if (this.started) {
|
||||
|
||||
@@ -173,4 +173,11 @@ describe('TunnelAgent', () => {
|
||||
});
|
||||
assert.equal(err.message, 'foo');
|
||||
});
|
||||
|
||||
it('should return stats', async () => {
|
||||
const agent = new TunnelAgent();
|
||||
assert.deepEqual(agent.stats(), {
|
||||
connectedSockets: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user