diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -7,13 +7,13 @@ if (isTestInstance()) { | |||
7 | } | 7 | } |
8 | 8 | ||
9 | // ----------- Node modules ----------- | 9 | // ----------- Node modules ----------- |
10 | import * as express from 'express' | 10 | import express from 'express' |
11 | import * as morgan from 'morgan' | 11 | import morgan, { token } from 'morgan' |
12 | import * as cors from 'cors' | 12 | import cors from 'cors' |
13 | import * as cookieParser from 'cookie-parser' | 13 | import cookieParser from 'cookie-parser' |
14 | import * as helmet from 'helmet' | 14 | import { frameguard } from 'helmet' |
15 | import * as useragent from 'useragent' | 15 | import { parse } from 'useragent' |
16 | import * as anonymize from 'ip-anonymize' | 16 | import anonymize from 'ip-anonymize' |
17 | import { program as cli } from 'commander' | 17 | import { program as cli } from 'commander' |
18 | 18 | ||
19 | process.title = 'peertube' | 19 | process.title = 'peertube' |
@@ -61,7 +61,7 @@ if (CONFIG.CSP.ENABLED) { | |||
61 | } | 61 | } |
62 | 62 | ||
63 | if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) { | 63 | if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) { |
64 | app.use(helmet.frameguard({ | 64 | app.use(frameguard({ |
65 | action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts | 65 | action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts |
66 | })) | 66 | })) |
67 | } | 67 | } |
@@ -148,16 +148,16 @@ if (isTestInstance()) { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | // For the logger | 150 | // For the logger |
151 | morgan.token('remote-addr', (req: express.Request) => { | 151 | token('remote-addr', (req: express.Request) => { |
152 | if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { | 152 | if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { |
153 | return anonymize(req.ip, 16, 16) | 153 | return anonymize(req.ip, 16, 16) |
154 | } | 154 | } |
155 | 155 | ||
156 | return req.ip | 156 | return req.ip |
157 | }) | 157 | }) |
158 | morgan.token('user-agent', (req: express.Request) => { | 158 | token('user-agent', (req: express.Request) => { |
159 | if (req.get('DNT') === '1') { | 159 | if (req.get('DNT') === '1') { |
160 | return useragent.parse(req.get('user-agent')).family | 160 | return parse(req.get('user-agent')).family |
161 | } | 161 | } |
162 | 162 | ||
163 | return req.get('user-agent') | 163 | return req.get('user-agent') |