bunch of changes

This commit is contained in:
Yaroslav Kukharuk
2021-02-24 13:55:49 +02:00
parent 7003f4cfe6
commit cf0679fa0b
10 changed files with 78 additions and 1201 deletions
+6 -5
View File
@@ -15,7 +15,6 @@ export default function(opt) {
const validHosts = (opt.domain) ? [opt.domain] : undefined;
const myTldjs = tldjs.fromUserSettings({ validHosts });
const landingPage = opt.landing || 'https://localtunnel.github.io/www/';
function GetClientIdFromHostname(hostname) {
return myTldjs.getSubdomain(hostname);
@@ -29,9 +28,9 @@ export default function(opt) {
const router = new Router();
router.get('/api/status', async (ctx, next) => {
const stats = manager.stats;
ctx.body = {
tunnels: stats.tunnels,
tunnelsCount: manager.stats.tunnels,
tunnels: manager.getClients(),
mem: process.memoryUsage(),
};
});
@@ -90,7 +89,8 @@ export default function(opt) {
}
// no new client request, send to landing page
ctx.redirect(landingPage);
const apiStatusUrl = schema + '://'+ ctx.request.host + '/api/status';
ctx.redirect(ctx.request.host);
});
// anything after the / path is a request for a specific client name
@@ -147,10 +147,11 @@ export default function(opt) {
return;
}
debug('Identified client ID as: %s', clientId);
const client = manager.getClient(clientId);
if (!client) {
res.statusCode = 404;
res.end('404');
res.end("Can't find active tunnel");
return;
}