X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Finitializers%2Fconfig.ts;h=9c270568953490480b99488fcaade2cd146df4b7;hb=2f63f629add5d24f8c01f309c7cae43b667b0c2a;hp=3a7c72a1caf376e71cdc61d619c23f5ec40e6ff7;hpb=97b6428af78d7b00d9b57e1a317d1355f5e76939;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 3a7c72a1c..9c2705689 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -1,13 +1,13 @@ import bytes from 'bytes' import { IConfig } from 'config' -import decache from 'decache' import { dirname, join } from 'path' +import { decacheModule } from '@server/helpers/decache' import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' import { BroadcastMessageLevel } from '@shared/models/server' -import { VideosRedundancyStrategy } from '../../shared/models' +import { buildPath, root } from '../../shared/core-utils' +import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' -// Do not use barrels, remain constants as independent as possible -import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' +import { parseBytes, parseDurationToMs } from '../helpers/core-utils' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -20,6 +20,9 @@ const CONFIG = { PORT: config.get('listen.port'), HOSTNAME: config.get('listen.hostname') }, + SECRETS: { + PEERTUBE: config.get('secrets.peertube') + }, DATABASE: { DBNAME: config.has('database.name') ? config.get('database.name') : 'peertube' + config.get('database.suffix'), HOSTNAME: config.get('database.hostname'), @@ -62,13 +65,41 @@ const CONFIG = { CLIENT: { VIDEOS: { MINIATURE: { - get PREFER_AUTHOR_DISPLAY_NAME () { return config.get('client.videos.miniature.prefer_author_display_name') } + get PREFER_AUTHOR_DISPLAY_NAME () { return config.get('client.videos.miniature.prefer_author_display_name') }, + get DISPLAY_AUTHOR_AVATAR () { return config.get('client.videos.miniature.display_author_avatar') } + }, + RESUMABLE_UPLOAD: { + get MAX_CHUNK_SIZE () { return parseBytes(config.get('client.videos.resumable_upload.max_chunk_size') || 0) } + } + }, + MENU: { + LOGIN: { + get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () { return config.get('client.menu.login.redirect_on_single_external_auth') } + } + } + }, + + DEFAULTS: { + PUBLISH: { + DOWNLOAD_ENABLED: config.get('defaults.publish.download_enabled'), + COMMENTS_ENABLED: config.get('defaults.publish.comments_enabled'), + PRIVACY: config.get('defaults.publish.privacy'), + LICENCE: config.get('defaults.publish.licence') + }, + P2P: { + WEBAPP: { + ENABLED: config.get('defaults.p2p.webapp.enabled') + }, + EMBED: { + ENABLED: config.get('defaults.p2p.embed.enabled') } } }, STORAGE: { TMP_DIR: buildPath(config.get('storage.tmp')), + TMP_PERSISTENT_DIR: buildPath(config.get('storage.tmp_persistent')), + BIN_DIR: buildPath(config.get('storage.bin')), ACTOR_IMAGES: buildPath(config.get('storage.avatars')), LOG_DIR: buildPath(config.get('storage.logs')), VIDEOS_DIR: buildPath(config.get('storage.videos')), @@ -80,17 +111,28 @@ const CONFIG = { TORRENTS_DIR: buildPath(config.get('storage.torrents')), CACHE_DIR: buildPath(config.get('storage.cache')), PLUGINS_DIR: buildPath(config.get('storage.plugins')), - CLIENT_OVERRIDES_DIR: buildPath(config.get('storage.client_overrides')) + CLIENT_OVERRIDES_DIR: buildPath(config.get('storage.client_overrides')), + WELL_KNOWN_DIR: buildPath(config.get('storage.well_known')) + }, + STATIC_FILES: { + PRIVATE_FILES_REQUIRE_AUTH: config.get('static_files.private_files_require_auth') }, OBJECT_STORAGE: { ENABLED: config.get('object_storage.enabled'), MAX_UPLOAD_PART: bytes.parse(config.get('object_storage.max_upload_part')), ENDPOINT: config.get('object_storage.endpoint'), REGION: config.get('object_storage.region'), + UPLOAD_ACL: { + PUBLIC: config.get('object_storage.upload_acl.public'), + PRIVATE: config.get('object_storage.upload_acl.private') + }, CREDENTIALS: { ACCESS_KEY_ID: config.get('object_storage.credentials.access_key_id'), SECRET_ACCESS_KEY: config.get('object_storage.credentials.secret_access_key') }, + PROXY: { + PROXIFY_PRIVATE_FILES: config.get('object_storage.proxy.proxify_private_files') + }, VIDEOS: { BUCKET_NAME: config.get('object_storage.videos.bucket_name'), PREFIX: config.get('object_storage.videos.prefix'), @@ -108,6 +150,12 @@ const CONFIG = { HOSTNAME: config.get('webserver.hostname'), PORT: config.get('webserver.port') }, + OAUTH2: { + TOKEN_LIFETIME: { + ACCESS_TOKEN: parseDurationToMs(config.get('oauth2.token_lifetime.access_token')), + REFRESH_TOKEN: parseDurationToMs(config.get('oauth2.token_lifetime.refresh_token')) + } + }, RATES_LIMIT: { API: { WINDOW_MS: parseDurationToMs(config.get('rates_limit.api.window')), @@ -121,6 +169,10 @@ const CONFIG = { WINDOW_MS: parseDurationToMs(config.get('rates_limit.login.window')), MAX: config.get('rates_limit.login.max') }, + RECEIVE_CLIENT_LOG: { + WINDOW_MS: parseDurationToMs(config.get('rates_limit.receive_client_log.window')), + MAX: config.get('rates_limit.receive_client_log.max') + }, ASK_SEND_EMAIL: { WINDOW_MS: parseDurationToMs(config.get('rates_limit.ask_send_email.window')), MAX: config.get('rates_limit.ask_send_email.max') @@ -136,7 +188,30 @@ const CONFIG = { }, ANONYMIZE_IP: config.get('log.anonymize_ip'), LOG_PING_REQUESTS: config.get('log.log_ping_requests'), - PRETTIFY_SQL: config.get('log.prettify_sql') + LOG_TRACKER_UNKNOWN_INFOHASH: config.get('log.log_tracker_unknown_infohash'), + PRETTIFY_SQL: config.get('log.prettify_sql'), + ACCEPT_CLIENT_LOG: config.get('log.accept_client_log') + }, + OPEN_TELEMETRY: { + METRICS: { + ENABLED: config.get('open_telemetry.metrics.enabled'), + + HTTP_REQUEST_DURATION: { + ENABLED: config.get('open_telemetry.metrics.http_request_duration.enabled') + }, + + PROMETHEUS_EXPORTER: { + HOSTNAME: config.get('open_telemetry.metrics.prometheus_exporter.hostname'), + PORT: config.get('open_telemetry.metrics.prometheus_exporter.port') + } + }, + TRACING: { + ENABLED: config.get('open_telemetry.tracing.enabled'), + + JAEGER_EXPORTER: { + ENDPOINT: config.get('open_telemetry.tracing.jaeger_exporter.endpoint') + } + } }, TRENDING: { VIDEOS: { @@ -166,6 +241,9 @@ const CONFIG = { SECURITY: { FRAMEGUARD: { ENABLED: config.get('security.frameguard.enabled') + }, + POWERED_BY_HEADER: { + ENABLED: config.get('security.powered_by_header.enabled') } }, TRACKER: { @@ -182,7 +260,15 @@ const CONFIG = { VIDEOS: { REMOTE: { MAX_AGE: parseDurationToMs(config.get('views.videos.remote.max_age')) - } + }, + LOCAL_BUFFER_UPDATE_INTERVAL: parseDurationToMs(config.get('views.videos.local_buffer_update_interval')), + IP_VIEW_EXPIRATION: parseDurationToMs(config.get('views.videos.ip_view_expiration')) + } + }, + GEO_IP: { + ENABLED: config.get('geo_ip.enabled'), + COUNTRY: { + DATABASE_URL: config.get('geo_ip.country.database_url') } }, PLUGINS: { @@ -211,6 +297,20 @@ const CONFIG = { } } }, + FEEDS: { + VIDEOS: { + COUNT: config.get('feeds.videos.count') + }, + COMMENTS: { + COUNT: config.get('feeds.comments.count') + } + }, + REMOTE_RUNNERS: { + STALLED_JOBS: { + LIVE: parseDurationToMs(config.get('remote_runners.stalled_jobs.live')), + VOD: parseDurationToMs(config.get('remote_runners.stalled_jobs.vod')) + } + }, ADMIN: { get EMAIL () { return config.get('admin.email') } }, @@ -219,6 +319,7 @@ const CONFIG = { }, SIGNUP: { get ENABLED () { return config.get('signup.enabled') }, + get REQUIRES_APPROVAL () { return config.get('signup.requires_approval') }, get LIMIT () { return config.get('signup.limit') }, get REQUIRES_EMAIL_VERIFICATION () { return config.get('signup.requires_email_verification') }, get MINIMUM_AGE () { return config.get('signup.minimum_age') }, @@ -230,9 +331,17 @@ const CONFIG = { } }, USER: { + HISTORY: { + VIDEOS: { + get ENABLED () { return config.get('user.history.videos.enabled') } + } + }, get VIDEO_QUOTA () { return parseBytes(config.get('user.video_quota')) }, get VIDEO_QUOTA_DAILY () { return parseBytes(config.get('user.video_quota_daily')) } }, + VIDEO_CHANNELS: { + get MAX_PER_USER () { return config.get('video_channels.max_per_user') } + }, TRANSCODING: { get ENABLED () { return config.get('transcoding.enabled') }, get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get('transcoding.allow_additional_extensions') }, @@ -240,8 +349,10 @@ const CONFIG = { get THREADS () { return config.get('transcoding.threads') }, get CONCURRENCY () { return config.get('transcoding.concurrency') }, get PROFILE () { return config.get('transcoding.profile') }, + get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () { return config.get('transcoding.always_transcode_original_resolution') }, RESOLUTIONS: { get '0p' () { return config.get('transcoding.resolutions.0p') }, + get '144p' () { return config.get('transcoding.resolutions.144p') }, get '240p' () { return config.get('transcoding.resolutions.240p') }, get '360p' () { return config.get('transcoding.resolutions.360p') }, get '480p' () { return config.get('transcoding.resolutions.480p') }, @@ -255,6 +366,9 @@ const CONFIG = { }, WEBTORRENT: { get ENABLED () { return config.get('transcoding.webtorrent.enabled') } + }, + REMOTE_RUNNERS: { + get ENABLED () { return config.get('transcoding.remote_runners.enabled') } } }, LIVE: { @@ -266,8 +380,24 @@ const CONFIG = { get ALLOW_REPLAY () { return config.get('live.allow_replay') }, + LATENCY_SETTING: { + get ENABLED () { return config.get('live.latency_setting.enabled') } + }, + RTMP: { - get PORT () { return config.get('live.rtmp.port') } + get ENABLED () { return config.get('live.rtmp.enabled') }, + get PORT () { return config.get('live.rtmp.port') }, + get HOSTNAME () { return config.get('live.rtmp.hostname') }, + get PUBLIC_HOSTNAME () { return config.get('live.rtmp.public_hostname') } + }, + + RTMPS: { + get ENABLED () { return config.get('live.rtmps.enabled') }, + get PORT () { return config.get('live.rtmps.port') }, + get HOSTNAME () { return config.get('live.rtmps.hostname') }, + get PUBLIC_HOSTNAME () { return config.get('live.rtmps.public_hostname') }, + get KEY_FILE () { return config.get('live.rtmps.key_file') }, + get CERT_FILE () { return config.get('live.rtmps.cert_file') } }, TRANSCODING: { @@ -275,7 +405,10 @@ const CONFIG = { get THREADS () { return config.get('live.transcoding.threads') }, get PROFILE () { return config.get('live.transcoding.profile') }, + get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () { return config.get('live.transcoding.always_transcode_original_resolution') }, + RESOLUTIONS: { + get '144p' () { return config.get('live.transcoding.resolutions.144p') }, get '240p' () { return config.get('live.transcoding.resolutions.240p') }, get '360p' () { return config.get('live.transcoding.resolutions.360p') }, get '480p' () { return config.get('live.transcoding.resolutions.480p') }, @@ -283,24 +416,48 @@ const CONFIG = { get '1080p' () { return config.get('live.transcoding.resolutions.1080p') }, get '1440p' () { return config.get('live.transcoding.resolutions.1440p') }, get '2160p' () { return config.get('live.transcoding.resolutions.2160p') } + }, + REMOTE_RUNNERS: { + get ENABLED () { return config.get('live.transcoding.remote_runners.enabled') } } } }, + VIDEO_STUDIO: { + get ENABLED () { return config.get('video_studio.enabled') }, + REMOTE_RUNNERS: { + get ENABLED () { return config.get('video_studio.remote_runners.enabled') } + } + }, IMPORT: { VIDEOS: { get CONCURRENCY () { return config.get('import.videos.concurrency') }, + get TIMEOUT () { return parseDurationToMs(config.get('import.videos.timeout')) }, HTTP: { get ENABLED () { return config.get('import.videos.http.enabled') }, - get FORCE_IPV4 () { return config.get('import.videos.http.force_ipv4') }, - PROXY: { - get ENABLED () { return config.get('import.videos.http.proxy.enabled') }, - get URL () { return config.get('import.videos.http.proxy.url') } - } + + YOUTUBE_DL_RELEASE: { + get URL () { return config.get('import.videos.http.youtube_dl_release.url') }, + get NAME () { return config.get('import.videos.http.youtube_dl_release.name') }, + get PYTHON_PATH () { return config.get('import.videos.http.youtube_dl_release.python_path') } + }, + + get FORCE_IPV4 () { return config.get('import.videos.http.force_ipv4') } }, TORRENT: { get ENABLED () { return config.get('import.videos.torrent.enabled') } } + }, + VIDEO_CHANNEL_SYNCHRONIZATION: { + get ENABLED () { return config.get('import.video_channel_synchronization.enabled') }, + get MAX_PER_USER () { return config.get('import.video_channel_synchronization.max_per_user') }, + get CHECK_INTERVAL () { return parseDurationToMs(config.get('import.video_channel_synchronization.check_interval')) }, + get VIDEOS_LIMIT_PER_SYNCHRONIZATION () { + return config.get('import.video_channel_synchronization.videos_limit_per_synchronization') + }, + get FULL_SYNC_VIDEOS_LIMIT () { + return config.get('import.video_channel_synchronization.full_sync_videos_limit') + } } }, AUTO_BLACKLIST: { @@ -402,6 +559,7 @@ const CONFIG = { get IS_DEFAULT_SEARCH () { return config.get('search.search_index.is_default_search') } } } + } function registerConfigChangedHandler (fun: Function) { @@ -480,7 +638,7 @@ export function reloadConfig () { delete require.cache[fileName] } - decache('config') + decacheModule('config') } purge()