diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-21 09:56:59 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-21 09:56:59 +0100 |
commit | 225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5 (patch) | |
tree | 9dc8fa039e820229fd3ecb386d6f63bf02e16698 /server/initializers/constants.ts | |
parent | 6725d05c5f71e0cdf0deba6692220b73e42e7ffa (diff) | |
download | PeerTube-225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5.tar.gz PeerTube-225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5.tar.zst PeerTube-225a89c2afbbe53cf39ffa7ea0cd485095a1d5f5.zip |
Sanitize url to not end with implicit ports
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r-- | server/initializers/constants.ts | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 2ea2aa6b9..100a77622 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -1,15 +1,15 @@ | |||
1 | import * as config from 'config' | 1 | import * as config from 'config' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { JobCategory, JobState, VideoRateType } from '../../shared/models' | 3 | import { JobCategory, JobState, VideoRateType } from '../../shared/models' |
4 | import { FollowState } from '../../shared/models/actors' | ||
5 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 4 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
5 | import { FollowState } from '../../shared/models/actors' | ||
6 | import { VideoPrivacy } from '../../shared/models/videos' | 6 | import { VideoPrivacy } from '../../shared/models/videos' |
7 | // Do not use barrels, remain constants as independent as possible | 7 | // Do not use barrels, remain constants as independent as possible |
8 | import { isTestInstance, root } from '../helpers/core-utils' | 8 | import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
9 | 9 | ||
10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
11 | 11 | ||
12 | const LAST_MIGRATION_VERSION = 135 | 12 | const LAST_MIGRATION_VERSION = 140 |
13 | 13 | ||
14 | // --------------------------------------------------------------------------- | 14 | // --------------------------------------------------------------------------- |
15 | 15 | ||
@@ -38,6 +38,44 @@ const OAUTH_LIFETIME = { | |||
38 | 38 | ||
39 | // --------------------------------------------------------------------------- | 39 | // --------------------------------------------------------------------------- |
40 | 40 | ||
41 | // Number of points we add/remove from a friend after a successful/bad request | ||
42 | const SERVERS_SCORE = { | ||
43 | PENALTY: -10, | ||
44 | BONUS: 10, | ||
45 | BASE: 100, | ||
46 | MAX: 1000 | ||
47 | } | ||
48 | |||
49 | const FOLLOW_STATES: { [ id: string ]: FollowState } = { | ||
50 | PENDING: 'pending', | ||
51 | ACCEPTED: 'accepted' | ||
52 | } | ||
53 | |||
54 | const REMOTE_SCHEME = { | ||
55 | HTTP: 'https', | ||
56 | WS: 'wss' | ||
57 | } | ||
58 | |||
59 | const JOB_STATES: { [ id: string ]: JobState } = { | ||
60 | PENDING: 'pending', | ||
61 | PROCESSING: 'processing', | ||
62 | ERROR: 'error', | ||
63 | SUCCESS: 'success' | ||
64 | } | ||
65 | const JOB_CATEGORIES: { [ id: string ]: JobCategory } = { | ||
66 | TRANSCODING: 'transcoding', | ||
67 | ACTIVITYPUB_HTTP: 'activitypub-http' | ||
68 | } | ||
69 | // How many maximum jobs we fetch from the database per cycle | ||
70 | const JOBS_FETCH_LIMIT_PER_CYCLE = { | ||
71 | transcoding: 10, | ||
72 | httpRequest: 20 | ||
73 | } | ||
74 | // 1 minutes | ||
75 | let JOBS_FETCHING_INTERVAL = 60000 | ||
76 | |||
77 | // --------------------------------------------------------------------------- | ||
78 | |||
41 | const CONFIG = { | 79 | const CONFIG = { |
42 | LISTEN: { | 80 | LISTEN: { |
43 | PORT: config.get<number>('listen.port') | 81 | PORT: config.get<number>('listen.port') |
@@ -93,8 +131,6 @@ const CONFIG = { | |||
93 | } | 131 | } |
94 | } | 132 | } |
95 | } | 133 | } |
96 | CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | ||
97 | CONFIG.WEBSERVER.HOST = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | ||
98 | 134 | ||
99 | const AVATARS_DIR = { | 135 | const AVATARS_DIR = { |
100 | ACCOUNT: join(CONFIG.STORAGE.AVATARS_DIR, 'account') | 136 | ACCOUNT: join(CONFIG.STORAGE.AVATARS_DIR, 'account') |
@@ -238,44 +274,6 @@ const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = { | |||
238 | 274 | ||
239 | // --------------------------------------------------------------------------- | 275 | // --------------------------------------------------------------------------- |
240 | 276 | ||
241 | // Number of points we add/remove from a friend after a successful/bad request | ||
242 | const SERVERS_SCORE = { | ||
243 | PENALTY: -10, | ||
244 | BONUS: 10, | ||
245 | BASE: 100, | ||
246 | MAX: 1000 | ||
247 | } | ||
248 | |||
249 | const FOLLOW_STATES: { [ id: string ]: FollowState } = { | ||
250 | PENDING: 'pending', | ||
251 | ACCEPTED: 'accepted' | ||
252 | } | ||
253 | |||
254 | const REMOTE_SCHEME = { | ||
255 | HTTP: 'https', | ||
256 | WS: 'wss' | ||
257 | } | ||
258 | |||
259 | const JOB_STATES: { [ id: string ]: JobState } = { | ||
260 | PENDING: 'pending', | ||
261 | PROCESSING: 'processing', | ||
262 | ERROR: 'error', | ||
263 | SUCCESS: 'success' | ||
264 | } | ||
265 | const JOB_CATEGORIES: { [ id: string ]: JobCategory } = { | ||
266 | TRANSCODING: 'transcoding', | ||
267 | ACTIVITYPUB_HTTP: 'activitypub-http' | ||
268 | } | ||
269 | // How many maximum jobs we fetch from the database per cycle | ||
270 | const JOBS_FETCH_LIMIT_PER_CYCLE = { | ||
271 | transcoding: 10, | ||
272 | httpRequest: 20 | ||
273 | } | ||
274 | // 1 minutes | ||
275 | let JOBS_FETCHING_INTERVAL = 60000 | ||
276 | |||
277 | // --------------------------------------------------------------------------- | ||
278 | |||
279 | const PRIVATE_RSA_KEY_SIZE = 2048 | 277 | const PRIVATE_RSA_KEY_SIZE = 2048 |
280 | 278 | ||
281 | // Password encryption | 279 | // Password encryption |
@@ -334,6 +332,9 @@ if (isTestInstance() === true) { | |||
334 | ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 | 332 | ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 |
335 | } | 333 | } |
336 | 334 | ||
335 | CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT) | ||
336 | CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) | ||
337 | |||
337 | // --------------------------------------------------------------------------- | 338 | // --------------------------------------------------------------------------- |
338 | 339 | ||
339 | export { | 340 | export { |