diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-11 10:56:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-11 10:58:09 +0200 |
commit | 5d79474cc66383ecbfcef6366f63a34c3af21cbf (patch) | |
tree | 6b2cd85c25294ca04c94cbbcc90353d25e9cee06 /server/controllers/api | |
parent | 2b3f1919fda81c2781ceeb9071d426c184e1b21c (diff) | |
download | PeerTube-5d79474cc66383ecbfcef6366f63a34c3af21cbf.tar.gz PeerTube-5d79474cc66383ecbfcef6366f63a34c3af21cbf.tar.zst PeerTube-5d79474cc66383ecbfcef6366f63a34c3af21cbf.zip |
Add debug component to help admins to fix IP issues
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/server/debug.ts | 25 | ||||
-rw-r--r-- | server/controllers/api/server/index.ts | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts new file mode 100644 index 000000000..4450038f6 --- /dev/null +++ b/server/controllers/api/server/debug.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import * as express from 'express' | ||
2 | import { UserRight } from '../../../../shared/models/users' | ||
3 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' | ||
4 | |||
5 | const debugRouter = express.Router() | ||
6 | |||
7 | debugRouter.get('/debug', | ||
8 | authenticate, | ||
9 | ensureUserHasRight(UserRight.MANAGE_DEBUG), | ||
10 | asyncMiddleware(getDebug) | ||
11 | ) | ||
12 | |||
13 | // --------------------------------------------------------------------------- | ||
14 | |||
15 | export { | ||
16 | debugRouter | ||
17 | } | ||
18 | |||
19 | // --------------------------------------------------------------------------- | ||
20 | |||
21 | async function getDebug (req: express.Request, res: express.Response) { | ||
22 | return res.json({ | ||
23 | ip: req.ip | ||
24 | }).end() | ||
25 | } | ||
diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts index de09588df..6b8793a19 100644 --- a/server/controllers/api/server/index.ts +++ b/server/controllers/api/server/index.ts | |||
@@ -5,6 +5,7 @@ import { serverRedundancyRouter } from './redundancy' | |||
5 | import { serverBlocklistRouter } from './server-blocklist' | 5 | import { serverBlocklistRouter } from './server-blocklist' |
6 | import { contactRouter } from './contact' | 6 | import { contactRouter } from './contact' |
7 | import { logsRouter } from './logs' | 7 | import { logsRouter } from './logs' |
8 | import { debugRouter } from './debug' | ||
8 | 9 | ||
9 | const serverRouter = express.Router() | 10 | const serverRouter = express.Router() |
10 | 11 | ||
@@ -14,6 +15,7 @@ serverRouter.use('/', statsRouter) | |||
14 | serverRouter.use('/', serverBlocklistRouter) | 15 | serverRouter.use('/', serverBlocklistRouter) |
15 | serverRouter.use('/', contactRouter) | 16 | serverRouter.use('/', contactRouter) |
16 | serverRouter.use('/', logsRouter) | 17 | serverRouter.use('/', logsRouter) |
18 | serverRouter.use('/', debugRouter) | ||
17 | 19 | ||
18 | // --------------------------------------------------------------------------- | 20 | // --------------------------------------------------------------------------- |
19 | 21 | ||