2021-08-27 14:32:44 +02:00
|
|
|
import bytes from 'bytes'
|
2019-04-11 11:33:44 +02:00
|
|
|
import { IConfig } from 'config'
|
|
|
|
import { dirname, join } from 'path'
|
2021-12-03 09:52:03 +01:00
|
|
|
import { decacheModule } from '@server/helpers/decache'
|
2021-04-09 09:37:46 +02:00
|
|
|
import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
|
|
|
|
import { BroadcastMessageLevel } from '@shared/models/server'
|
2022-03-04 13:40:02 +01:00
|
|
|
import { buildPath, root } from '../../shared/core-utils'
|
2021-12-14 17:17:01 +01:00
|
|
|
import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models'
|
2021-04-09 09:37:46 +02:00
|
|
|
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
|
2021-11-02 19:11:20 +01:00
|
|
|
import { parseBytes, parseDurationToMs } from '../helpers/core-utils'
|
2019-04-11 11:33:44 +02:00
|
|
|
|
|
|
|
// Use a variable to reload the configuration if we need
|
|
|
|
let config: IConfig = require('config')
|
|
|
|
|
|
|
|
const configChangedHandlers: Function[] = []
|
|
|
|
|
|
|
|
const CONFIG = {
|
|
|
|
CUSTOM_FILE: getLocalConfigFilePath(),
|
|
|
|
LISTEN: {
|
|
|
|
PORT: config.get<number>('listen.port'),
|
|
|
|
HOSTNAME: config.get<string>('listen.hostname')
|
|
|
|
},
|
2022-10-10 11:12:23 +02:00
|
|
|
SECRETS: {
|
|
|
|
PEERTUBE: config.get<string>('secrets.peertube')
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
DATABASE: {
|
2020-06-24 19:48:04 +02:00
|
|
|
DBNAME: config.has('database.name') ? config.get<string>('database.name') : 'peertube' + config.get<string>('database.suffix'),
|
2019-04-11 11:33:44 +02:00
|
|
|
HOSTNAME: config.get<string>('database.hostname'),
|
|
|
|
PORT: config.get<number>('database.port'),
|
2020-08-24 11:38:57 +02:00
|
|
|
SSL: config.get<boolean>('database.ssl'),
|
2019-04-11 11:33:44 +02:00
|
|
|
USERNAME: config.get<string>('database.username'),
|
|
|
|
PASSWORD: config.get<string>('database.password'),
|
|
|
|
POOL: {
|
|
|
|
MAX: config.get<number>('database.pool.max')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
REDIS: {
|
|
|
|
HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null,
|
|
|
|
PORT: config.has('redis.port') ? config.get<number>('redis.port') : null,
|
|
|
|
SOCKET: config.has('redis.socket') ? config.get<string>('redis.socket') : null,
|
|
|
|
AUTH: config.has('redis.auth') ? config.get<string>('redis.auth') : null,
|
|
|
|
DB: config.has('redis.db') ? config.get<number>('redis.db') : null
|
|
|
|
},
|
|
|
|
SMTP: {
|
2019-02-13 12:16:27 +01:00
|
|
|
TRANSPORT: config.has('smtp.transport') ? config.get<string>('smtp.transport') : 'smtp',
|
|
|
|
SENDMAIL: config.has('smtp.sendmail') ? config.get<string>('smtp.sendmail') : null,
|
2019-04-11 11:33:44 +02:00
|
|
|
HOSTNAME: config.get<string>('smtp.hostname'),
|
|
|
|
PORT: config.get<number>('smtp.port'),
|
|
|
|
USERNAME: config.get<string>('smtp.username'),
|
|
|
|
PASSWORD: config.get<string>('smtp.password'),
|
|
|
|
TLS: config.get<boolean>('smtp.tls'),
|
|
|
|
DISABLE_STARTTLS: config.get<boolean>('smtp.disable_starttls'),
|
|
|
|
CA_FILE: config.get<string>('smtp.ca_file'),
|
|
|
|
FROM_ADDRESS: config.get<string>('smtp.from_address')
|
|
|
|
},
|
2019-05-17 14:10:19 +02:00
|
|
|
EMAIL: {
|
|
|
|
BODY: {
|
|
|
|
SIGNATURE: config.get<string>('email.body.signature')
|
|
|
|
},
|
2019-08-22 10:22:01 +02:00
|
|
|
SUBJECT: {
|
|
|
|
PREFIX: config.get<string>('email.subject.prefix') + ' '
|
2019-05-17 14:10:19 +02:00
|
|
|
}
|
|
|
|
},
|
2021-10-12 14:23:44 +02:00
|
|
|
|
|
|
|
CLIENT: {
|
|
|
|
VIDEOS: {
|
|
|
|
MINIATURE: {
|
2022-03-08 13:39:27 +01:00
|
|
|
get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') },
|
|
|
|
get DISPLAY_AUTHOR_AVATAR () { return config.get<boolean>('client.videos.miniature.display_author_avatar') }
|
2022-03-16 10:57:36 +01:00
|
|
|
},
|
|
|
|
RESUMABLE_UPLOAD: {
|
|
|
|
get MAX_CHUNK_SIZE () { return parseBytes(config.get<number>('client.videos.resumable_upload.max_chunk_size') || 0) }
|
2021-10-12 14:23:44 +02:00
|
|
|
}
|
2021-12-03 17:04:47 +01:00
|
|
|
},
|
|
|
|
MENU: {
|
|
|
|
LOGIN: {
|
|
|
|
get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () { return config.get<boolean>('client.menu.login.redirect_on_single_external_auth') }
|
|
|
|
}
|
2021-10-12 14:23:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-12-14 17:17:01 +01:00
|
|
|
DEFAULTS: {
|
|
|
|
PUBLISH: {
|
|
|
|
DOWNLOAD_ENABLED: config.get<boolean>('defaults.publish.download_enabled'),
|
|
|
|
COMMENTS_ENABLED: config.get<boolean>('defaults.publish.comments_enabled'),
|
|
|
|
PRIVACY: config.get<VideoPrivacy>('defaults.publish.privacy'),
|
|
|
|
LICENCE: config.get<number>('defaults.publish.licence')
|
2021-12-15 15:58:10 +01:00
|
|
|
},
|
|
|
|
P2P: {
|
2021-12-16 09:38:27 +01:00
|
|
|
WEBAPP: {
|
|
|
|
ENABLED: config.get<boolean>('defaults.p2p.webapp.enabled')
|
|
|
|
},
|
|
|
|
EMBED: {
|
|
|
|
ENABLED: config.get<boolean>('defaults.p2p.embed.enabled')
|
|
|
|
}
|
2021-12-14 17:17:01 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
STORAGE: {
|
|
|
|
TMP_DIR: buildPath(config.get<string>('storage.tmp')),
|
2023-05-03 15:17:11 +02:00
|
|
|
TMP_PERSISTENT_DIR: buildPath(config.get<string>('storage.tmp_persistent')),
|
2021-10-21 16:28:39 +02:00
|
|
|
BIN_DIR: buildPath(config.get<string>('storage.bin')),
|
2021-04-06 11:35:56 +02:00
|
|
|
ACTOR_IMAGES: buildPath(config.get<string>('storage.avatars')),
|
2019-04-11 11:33:44 +02:00
|
|
|
LOG_DIR: buildPath(config.get<string>('storage.logs')),
|
|
|
|
VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
|
|
|
|
STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')),
|
|
|
|
REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
|
|
|
|
THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
|
|
|
|
PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
|
|
|
|
CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')),
|
|
|
|
TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')),
|
2019-07-05 13:54:32 +02:00
|
|
|
CACHE_DIR: buildPath(config.get<string>('storage.cache')),
|
2020-07-10 10:20:11 +02:00
|
|
|
PLUGINS_DIR: buildPath(config.get<string>('storage.plugins')),
|
2022-10-04 10:53:00 +02:00
|
|
|
CLIENT_OVERRIDES_DIR: buildPath(config.get<string>('storage.client_overrides')),
|
|
|
|
WELL_KNOWN_DIR: buildPath(config.get<string>('storage.well_known'))
|
2019-04-11 11:33:44 +02:00
|
|
|
},
|
2022-10-26 16:23:39 +02:00
|
|
|
STATIC_FILES: {
|
|
|
|
PRIVATE_FILES_REQUIRE_AUTH: config.get<boolean>('static_files.private_files_require_auth')
|
|
|
|
},
|
2021-08-17 08:26:20 +02:00
|
|
|
OBJECT_STORAGE: {
|
|
|
|
ENABLED: config.get<boolean>('object_storage.enabled'),
|
|
|
|
MAX_UPLOAD_PART: bytes.parse(config.get<string>('object_storage.max_upload_part')),
|
|
|
|
ENDPOINT: config.get<string>('object_storage.endpoint'),
|
|
|
|
REGION: config.get<string>('object_storage.region'),
|
2022-10-19 10:43:53 +02:00
|
|
|
UPLOAD_ACL: {
|
|
|
|
PUBLIC: config.get<string>('object_storage.upload_acl.public'),
|
|
|
|
PRIVATE: config.get<string>('object_storage.upload_acl.private')
|
|
|
|
},
|
2021-08-17 08:26:20 +02:00
|
|
|
CREDENTIALS: {
|
|
|
|
ACCESS_KEY_ID: config.get<string>('object_storage.credentials.access_key_id'),
|
|
|
|
SECRET_ACCESS_KEY: config.get<string>('object_storage.credentials.secret_access_key')
|
|
|
|
},
|
2022-10-26 16:23:39 +02:00
|
|
|
PROXY: {
|
|
|
|
PROXIFY_PRIVATE_FILES: config.get<boolean>('object_storage.proxy.proxify_private_files')
|
|
|
|
},
|
2021-08-17 08:26:20 +02:00
|
|
|
VIDEOS: {
|
|
|
|
BUCKET_NAME: config.get<string>('object_storage.videos.bucket_name'),
|
|
|
|
PREFIX: config.get<string>('object_storage.videos.prefix'),
|
|
|
|
BASE_URL: config.get<string>('object_storage.videos.base_url')
|
|
|
|
},
|
|
|
|
STREAMING_PLAYLISTS: {
|
|
|
|
BUCKET_NAME: config.get<string>('object_storage.streaming_playlists.bucket_name'),
|
|
|
|
PREFIX: config.get<string>('object_storage.streaming_playlists.prefix'),
|
|
|
|
BASE_URL: config.get<string>('object_storage.streaming_playlists.base_url')
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
WEBSERVER: {
|
|
|
|
SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http',
|
|
|
|
WS: config.get<boolean>('webserver.https') === true ? 'wss' : 'ws',
|
|
|
|
HOSTNAME: config.get<string>('webserver.hostname'),
|
|
|
|
PORT: config.get<number>('webserver.port')
|
|
|
|
},
|
2022-12-29 14:18:07 +01:00
|
|
|
OAUTH2: {
|
|
|
|
TOKEN_LIFETIME: {
|
|
|
|
ACCESS_TOKEN: parseDurationToMs(config.get<string>('oauth2.token_lifetime.access_token')),
|
|
|
|
REFRESH_TOKEN: parseDurationToMs(config.get<string>('oauth2.token_lifetime.refresh_token'))
|
|
|
|
}
|
|
|
|
},
|
2019-04-26 13:48:55 +02:00
|
|
|
RATES_LIMIT: {
|
2019-07-04 16:42:40 +02:00
|
|
|
API: {
|
|
|
|
WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.api.window')),
|
|
|
|
MAX: config.get<number>('rates_limit.api.max')
|
|
|
|
},
|
|
|
|
SIGNUP: {
|
|
|
|
WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.signup.window')),
|
|
|
|
MAX: config.get<number>('rates_limit.signup.max')
|
|
|
|
},
|
2019-04-26 13:48:55 +02:00
|
|
|
LOGIN: {
|
|
|
|
WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.login.window')),
|
|
|
|
MAX: config.get<number>('rates_limit.login.max')
|
|
|
|
},
|
2022-07-15 15:30:14 +02:00
|
|
|
RECEIVE_CLIENT_LOG: {
|
|
|
|
WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.receive_client_log.window')),
|
|
|
|
MAX: config.get<number>('rates_limit.receive_client_log.max')
|
|
|
|
},
|
2019-04-26 13:48:55 +02:00
|
|
|
ASK_SEND_EMAIL: {
|
|
|
|
WINDOW_MS: parseDurationToMs(config.get<string>('rates_limit.ask_send_email.window')),
|
|
|
|
MAX: config.get<number>('rates_limit.ask_send_email.max')
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
TRUST_PROXY: config.get<string[]>('trust_proxy'),
|
|
|
|
LOG: {
|
2019-06-11 14:30:44 +02:00
|
|
|
LEVEL: config.get<string>('log.level'),
|
2019-12-12 17:15:38 +01:00
|
|
|
ROTATION: {
|
|
|
|
ENABLED: config.get<boolean>('log.rotation.enabled'),
|
2021-10-20 16:14:55 +02:00
|
|
|
MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.max_file_size')),
|
|
|
|
MAX_FILES: config.get<number>('log.rotation.max_files')
|
2019-12-12 17:15:38 +01:00
|
|
|
},
|
2021-10-20 16:14:55 +02:00
|
|
|
ANONYMIZE_IP: config.get<boolean>('log.anonymize_ip'),
|
2021-01-26 09:54:32 +01:00
|
|
|
LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests'),
|
2022-06-30 09:13:11 +02:00
|
|
|
LOG_TRACKER_UNKNOWN_INFOHASH: config.get<boolean>('log.log_tracker_unknown_infohash'),
|
2022-07-15 15:30:14 +02:00
|
|
|
PRETTIFY_SQL: config.get<boolean>('log.prettify_sql'),
|
|
|
|
ACCEPT_CLIENT_LOG: config.get<boolean>('log.accept_client_log')
|
2019-04-11 11:33:44 +02:00
|
|
|
},
|
2022-07-05 15:43:21 +02:00
|
|
|
OPEN_TELEMETRY: {
|
|
|
|
METRICS: {
|
|
|
|
ENABLED: config.get<boolean>('open_telemetry.metrics.enabled'),
|
|
|
|
|
2023-02-27 13:53:54 +01:00
|
|
|
HTTP_REQUEST_DURATION: {
|
|
|
|
ENABLED: config.get<boolean>('open_telemetry.metrics.http_request_duration.enabled')
|
|
|
|
},
|
|
|
|
|
2022-07-05 15:43:21 +02:00
|
|
|
PROMETHEUS_EXPORTER: {
|
2022-11-15 13:56:04 +01:00
|
|
|
HOSTNAME: config.get<string>('open_telemetry.metrics.prometheus_exporter.hostname'),
|
2022-07-05 15:43:21 +02:00
|
|
|
PORT: config.get<number>('open_telemetry.metrics.prometheus_exporter.port')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
TRACING: {
|
|
|
|
ENABLED: config.get<boolean>('open_telemetry.tracing.enabled'),
|
|
|
|
|
|
|
|
JAEGER_EXPORTER: {
|
|
|
|
ENDPOINT: config.get<string>('open_telemetry.tracing.jaeger_exporter.endpoint')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
TRENDING: {
|
|
|
|
VIDEOS: {
|
2021-01-27 17:15:21 +01:00
|
|
|
INTERVAL_DAYS: config.get<number>('trending.videos.interval_days'),
|
|
|
|
ALGORITHMS: {
|
|
|
|
get ENABLED () { return config.get<string[]>('trending.videos.algorithms.enabled') },
|
|
|
|
get DEFAULT () { return config.get<string>('trending.videos.algorithms.default') }
|
|
|
|
}
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
REDUNDANCY: {
|
|
|
|
VIDEOS: {
|
2019-04-11 15:38:53 +02:00
|
|
|
CHECK_INTERVAL: parseDurationToMs(config.get<string>('redundancy.videos.check_interval')),
|
2019-04-11 11:33:44 +02:00
|
|
|
STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
|
|
|
|
}
|
|
|
|
},
|
2020-04-07 15:27:41 +02:00
|
|
|
REMOTE_REDUNDANCY: {
|
|
|
|
VIDEOS: {
|
|
|
|
ACCEPT_FROM: config.get<VideoRedundancyConfigFilter>('remote_redundancy.videos.accept_from')
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
CSP: {
|
|
|
|
ENABLED: config.get<boolean>('csp.enabled'),
|
|
|
|
REPORT_ONLY: config.get<boolean>('csp.report_only'),
|
2020-08-25 13:54:59 +02:00
|
|
|
REPORT_URI: config.get<string>('csp.report_uri')
|
2019-04-11 11:33:44 +02:00
|
|
|
},
|
2021-04-12 15:33:54 +02:00
|
|
|
SECURITY: {
|
|
|
|
FRAMEGUARD: {
|
|
|
|
ENABLED: config.get<boolean>('security.frameguard.enabled')
|
2023-02-27 09:22:59 +01:00
|
|
|
},
|
|
|
|
POWERED_BY_HEADER: {
|
|
|
|
ENABLED: config.get<boolean>('security.powered_by_header.enabled')
|
2021-04-12 15:33:54 +02:00
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
TRACKER: {
|
|
|
|
ENABLED: config.get<boolean>('tracker.enabled'),
|
|
|
|
PRIVATE: config.get<boolean>('tracker.private'),
|
|
|
|
REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces')
|
|
|
|
},
|
2019-04-11 15:38:53 +02:00
|
|
|
HISTORY: {
|
|
|
|
VIDEOS: {
|
|
|
|
MAX_AGE: parseDurationToMs(config.get('history.videos.max_age'))
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 17:33:36 +02:00
|
|
|
VIEWS: {
|
|
|
|
VIDEOS: {
|
|
|
|
REMOTE: {
|
|
|
|
MAX_AGE: parseDurationToMs(config.get('views.videos.remote.max_age'))
|
2021-11-09 10:11:20 +01:00
|
|
|
},
|
|
|
|
LOCAL_BUFFER_UPDATE_INTERVAL: parseDurationToMs(config.get('views.videos.local_buffer_update_interval')),
|
|
|
|
IP_VIEW_EXPIRATION: parseDurationToMs(config.get('views.videos.ip_view_expiration'))
|
2019-04-11 17:33:36 +02:00
|
|
|
}
|
|
|
|
},
|
2022-03-24 13:36:47 +01:00
|
|
|
GEO_IP: {
|
|
|
|
ENABLED: config.get<boolean>('geo_ip.enabled'),
|
|
|
|
COUNTRY: {
|
|
|
|
DATABASE_URL: config.get<string>('geo_ip.country.database_url')
|
|
|
|
}
|
|
|
|
},
|
2019-07-16 11:33:22 +02:00
|
|
|
PLUGINS: {
|
|
|
|
INDEX: {
|
|
|
|
ENABLED: config.get<boolean>('plugins.index.enabled'),
|
2019-07-16 15:03:00 +02:00
|
|
|
CHECK_LATEST_VERSIONS_INTERVAL: parseDurationToMs(config.get<string>('plugins.index.check_latest_versions_interval')),
|
|
|
|
URL: config.get<string>('plugins.index.url')
|
2019-07-16 11:33:22 +02:00
|
|
|
}
|
|
|
|
},
|
2020-06-03 09:42:07 +02:00
|
|
|
FEDERATION: {
|
|
|
|
VIDEOS: {
|
2021-02-26 16:26:27 +01:00
|
|
|
FEDERATE_UNLISTED: config.get<boolean>('federation.videos.federate_unlisted'),
|
|
|
|
CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions')
|
2020-06-03 09:42:07 +02:00
|
|
|
}
|
|
|
|
},
|
2021-03-11 16:54:52 +01:00
|
|
|
PEERTUBE: {
|
|
|
|
CHECK_LATEST_VERSION: {
|
|
|
|
ENABLED: config.get<boolean>('peertube.check_latest_version.enabled'),
|
|
|
|
URL: config.get<string>('peertube.check_latest_version.url')
|
|
|
|
}
|
|
|
|
},
|
2021-10-12 13:33:44 +02:00
|
|
|
WEBADMIN: {
|
|
|
|
CONFIGURATION: {
|
2021-10-14 11:35:43 +02:00
|
|
|
EDITION: {
|
|
|
|
ALLOWED: config.get<boolean>('webadmin.configuration.edition.allowed')
|
2021-10-12 13:33:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-05-24 15:56:23 +02:00
|
|
|
FEEDS: {
|
|
|
|
VIDEOS: {
|
|
|
|
COUNT: config.get<number>('feeds.videos.count')
|
|
|
|
},
|
|
|
|
COMMENTS: {
|
|
|
|
COUNT: config.get<number>('feeds.comments.count')
|
|
|
|
}
|
|
|
|
},
|
2023-04-21 14:55:10 +02:00
|
|
|
REMOTE_RUNNERS: {
|
|
|
|
STALLED_JOBS: {
|
|
|
|
LIVE: parseDurationToMs(config.get<string>('remote_runners.stalled_jobs.live')),
|
|
|
|
VOD: parseDurationToMs(config.get<string>('remote_runners.stalled_jobs.vod'))
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
ADMIN: {
|
|
|
|
get EMAIL () { return config.get<string>('admin.email') }
|
|
|
|
},
|
|
|
|
CONTACT_FORM: {
|
|
|
|
get ENABLED () { return config.get<boolean>('contact_form.enabled') }
|
|
|
|
},
|
|
|
|
SIGNUP: {
|
|
|
|
get ENABLED () { return config.get<boolean>('signup.enabled') },
|
2023-01-19 09:27:16 +01:00
|
|
|
get REQUIRES_APPROVAL () { return config.get<boolean>('signup.requires_approval') },
|
2019-04-11 11:33:44 +02:00
|
|
|
get LIMIT () { return config.get<number>('signup.limit') },
|
|
|
|
get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') },
|
2021-04-24 11:57:01 +02:00
|
|
|
get MINIMUM_AGE () { return config.get<number>('signup.minimum_age') },
|
2019-04-11 11:33:44 +02:00
|
|
|
FILTERS: {
|
|
|
|
CIDR: {
|
|
|
|
get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') },
|
|
|
|
get BLACKLIST () { return config.get<string[]>('signup.filters.cidr.blacklist') }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
USER: {
|
2023-04-07 10:09:54 +02:00
|
|
|
HISTORY: {
|
|
|
|
VIDEOS: {
|
|
|
|
get ENABLED () { return config.get<boolean>('user.history.videos.enabled') }
|
|
|
|
}
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
|
|
|
|
get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }
|
|
|
|
},
|
2021-10-26 16:42:10 +02:00
|
|
|
VIDEO_CHANNELS: {
|
|
|
|
get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') }
|
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
TRANSCODING: {
|
|
|
|
get ENABLED () { return config.get<boolean>('transcoding.enabled') },
|
|
|
|
get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') },
|
2019-05-16 16:55:34 +02:00
|
|
|
get ALLOW_AUDIO_FILES () { return config.get<boolean>('transcoding.allow_audio_files') },
|
2019-04-11 11:33:44 +02:00
|
|
|
get THREADS () { return config.get<number>('transcoding.threads') },
|
2021-02-08 10:51:10 +01:00
|
|
|
get CONCURRENCY () { return config.get<number>('transcoding.concurrency') },
|
2021-01-28 15:52:44 +01:00
|
|
|
get PROFILE () { return config.get<string>('transcoding.profile') },
|
2022-08-05 10:36:19 +02:00
|
|
|
get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () { return config.get<boolean>('transcoding.always_transcode_original_resolution') },
|
2019-04-11 11:33:44 +02:00
|
|
|
RESOLUTIONS: {
|
2019-11-01 02:06:19 +01:00
|
|
|
get '0p' () { return config.get<boolean>('transcoding.resolutions.0p') },
|
2021-11-05 10:23:02 +01:00
|
|
|
get '144p' () { return config.get<boolean>('transcoding.resolutions.144p') },
|
2019-04-11 11:33:44 +02:00
|
|
|
get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
|
|
|
|
get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') },
|
|
|
|
get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') },
|
|
|
|
get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') },
|
2019-06-12 17:26:23 +02:00
|
|
|
get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') },
|
2020-12-24 18:02:04 +01:00
|
|
|
get '1440p' () { return config.get<boolean>('transcoding.resolutions.1440p') },
|
2019-06-12 17:26:23 +02:00
|
|
|
get '2160p' () { return config.get<boolean>('transcoding.resolutions.2160p') }
|
2019-04-11 11:33:44 +02:00
|
|
|
},
|
|
|
|
HLS: {
|
|
|
|
get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }
|
2019-11-15 15:06:03 +01:00
|
|
|
},
|
|
|
|
WEBTORRENT: {
|
|
|
|
get ENABLED () { return config.get<boolean>('transcoding.webtorrent.enabled') }
|
2023-04-21 14:55:10 +02:00
|
|
|
},
|
|
|
|
REMOTE_RUNNERS: {
|
|
|
|
get ENABLED () { return config.get<boolean>('transcoding.remote_runners.enabled') }
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
},
|
2020-09-17 09:20:52 +02:00
|
|
|
LIVE: {
|
|
|
|
get ENABLED () { return config.get<boolean>('live.enabled') },
|
2020-09-25 16:19:35 +02:00
|
|
|
|
|
|
|
get MAX_DURATION () { return parseDurationToMs(config.get<string>('live.max_duration')) },
|
2020-10-28 15:24:40 +01:00
|
|
|
get MAX_INSTANCE_LIVES () { return config.get<number>('live.max_instance_lives') },
|
|
|
|
get MAX_USER_LIVES () { return config.get<number>('live.max_user_lives') },
|
|
|
|
|
2020-09-25 16:19:35 +02:00
|
|
|
get ALLOW_REPLAY () { return config.get<boolean>('live.allow_replay') },
|
2020-09-17 09:20:52 +02:00
|
|
|
|
2022-03-04 13:40:02 +01:00
|
|
|
LATENCY_SETTING: {
|
|
|
|
get ENABLED () { return config.get<boolean>('live.latency_setting.enabled') }
|
|
|
|
},
|
|
|
|
|
2020-09-17 09:20:52 +02:00
|
|
|
RTMP: {
|
2021-11-05 11:36:03 +01:00
|
|
|
get ENABLED () { return config.get<boolean>('live.rtmp.enabled') },
|
2022-03-01 13:37:34 +01:00
|
|
|
get PORT () { return config.get<number>('live.rtmp.port') },
|
2022-05-02 14:32:12 +02:00
|
|
|
get HOSTNAME () { return config.get<number>('live.rtmp.hostname') },
|
|
|
|
get PUBLIC_HOSTNAME () { return config.get<number>('live.rtmp.public_hostname') }
|
2020-09-17 09:20:52 +02:00
|
|
|
},
|
|
|
|
|
2021-11-05 11:36:03 +01:00
|
|
|
RTMPS: {
|
|
|
|
get ENABLED () { return config.get<boolean>('live.rtmps.enabled') },
|
|
|
|
get PORT () { return config.get<number>('live.rtmps.port') },
|
2022-03-01 13:37:34 +01:00
|
|
|
get HOSTNAME () { return config.get<number>('live.rtmps.hostname') },
|
2022-05-02 14:32:12 +02:00
|
|
|
get PUBLIC_HOSTNAME () { return config.get<number>('live.rtmps.public_hostname') },
|
2021-11-05 11:36:03 +01:00
|
|
|
get KEY_FILE () { return config.get<string>('live.rtmps.key_file') },
|
|
|
|
get CERT_FILE () { return config.get<string>('live.rtmps.cert_file') }
|
|
|
|
},
|
|
|
|
|
2020-09-17 09:20:52 +02:00
|
|
|
TRANSCODING: {
|
|
|
|
get ENABLED () { return config.get<boolean>('live.transcoding.enabled') },
|
|
|
|
get THREADS () { return config.get<number>('live.transcoding.threads') },
|
2021-01-28 15:52:44 +01:00
|
|
|
get PROFILE () { return config.get<string>('live.transcoding.profile') },
|
2020-09-17 09:20:52 +02:00
|
|
|
|
2022-08-05 10:36:19 +02:00
|
|
|
get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () { return config.get<boolean>('live.transcoding.always_transcode_original_resolution') },
|
|
|
|
|
2020-09-17 09:20:52 +02:00
|
|
|
RESOLUTIONS: {
|
2021-11-05 10:23:02 +01:00
|
|
|
get '144p' () { return config.get<boolean>('live.transcoding.resolutions.144p') },
|
2020-09-17 09:20:52 +02:00
|
|
|
get '240p' () { return config.get<boolean>('live.transcoding.resolutions.240p') },
|
|
|
|
get '360p' () { return config.get<boolean>('live.transcoding.resolutions.360p') },
|
|
|
|
get '480p' () { return config.get<boolean>('live.transcoding.resolutions.480p') },
|
|
|
|
get '720p' () { return config.get<boolean>('live.transcoding.resolutions.720p') },
|
|
|
|
get '1080p' () { return config.get<boolean>('live.transcoding.resolutions.1080p') },
|
2020-12-24 18:02:04 +01:00
|
|
|
get '1440p' () { return config.get<boolean>('live.transcoding.resolutions.1440p') },
|
2020-09-17 09:20:52 +02:00
|
|
|
get '2160p' () { return config.get<boolean>('live.transcoding.resolutions.2160p') }
|
2023-04-21 14:55:10 +02:00
|
|
|
},
|
|
|
|
REMOTE_RUNNERS: {
|
|
|
|
get ENABLED () { return config.get<boolean>('live.transcoding.remote_runners.enabled') }
|
2020-09-17 09:20:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-03-22 16:58:49 +01:00
|
|
|
VIDEO_STUDIO: {
|
|
|
|
get ENABLED () { return config.get<boolean>('video_studio.enabled') }
|
2022-02-11 10:51:33 +01:00
|
|
|
},
|
2019-04-11 11:33:44 +02:00
|
|
|
IMPORT: {
|
|
|
|
VIDEOS: {
|
2021-02-08 10:51:10 +01:00
|
|
|
get CONCURRENCY () { return config.get<number>('import.videos.concurrency') },
|
2022-05-24 14:55:07 +02:00
|
|
|
get TIMEOUT () { return parseDurationToMs(config.get<string>('import.videos.timeout')) },
|
2021-02-08 10:51:10 +01:00
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
HTTP: {
|
2020-01-21 15:59:57 +01:00
|
|
|
get ENABLED () { return config.get<boolean>('import.videos.http.enabled') },
|
2021-10-21 16:28:39 +02:00
|
|
|
|
|
|
|
YOUTUBE_DL_RELEASE: {
|
|
|
|
get URL () { return config.get<string>('import.videos.http.youtube_dl_release.url') },
|
2022-01-09 17:21:45 +01:00
|
|
|
get NAME () { return config.get<string>('import.videos.http.youtube_dl_release.name') },
|
|
|
|
get PYTHON_PATH () { return config.get<string>('import.videos.http.youtube_dl_release.python_path') }
|
2021-10-21 16:28:39 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
get FORCE_IPV4 () { return config.get<boolean>('import.videos.http.force_ipv4') }
|
2019-04-11 11:33:44 +02:00
|
|
|
},
|
|
|
|
TORRENT: {
|
|
|
|
get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') }
|
|
|
|
}
|
2022-08-10 09:53:39 +02:00
|
|
|
},
|
|
|
|
VIDEO_CHANNEL_SYNCHRONIZATION: {
|
|
|
|
get ENABLED () { return config.get<boolean>('import.video_channel_synchronization.enabled') },
|
|
|
|
get MAX_PER_USER () { return config.get<number>('import.video_channel_synchronization.max_per_user') },
|
|
|
|
get CHECK_INTERVAL () { return parseDurationToMs(config.get<string>('import.video_channel_synchronization.check_interval')) },
|
|
|
|
get VIDEOS_LIMIT_PER_SYNCHRONIZATION () {
|
|
|
|
return config.get<number>('import.video_channel_synchronization.videos_limit_per_synchronization')
|
2022-11-14 11:11:39 +01:00
|
|
|
},
|
|
|
|
get FULL_SYNC_VIDEOS_LIMIT () {
|
|
|
|
return config.get<number>('import.video_channel_synchronization.full_sync_videos_limit')
|
2022-08-10 09:53:39 +02:00
|
|
|
}
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
AUTO_BLACKLIST: {
|
|
|
|
VIDEOS: {
|
|
|
|
OF_USERS: {
|
|
|
|
get ENABLED () { return config.get<boolean>('auto_blacklist.videos.of_users.enabled') }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CACHE: {
|
|
|
|
PREVIEWS: {
|
|
|
|
get SIZE () { return config.get<number>('cache.previews.size') }
|
|
|
|
},
|
|
|
|
VIDEO_CAPTIONS: {
|
|
|
|
get SIZE () { return config.get<number>('cache.captions.size') }
|
2021-02-16 16:25:53 +01:00
|
|
|
},
|
|
|
|
TORRENTS: {
|
|
|
|
get SIZE () { return config.get<number>('cache.torrents.size') }
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
INSTANCE: {
|
|
|
|
get NAME () { return config.get<string>('instance.name') },
|
|
|
|
get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
|
|
|
|
get DESCRIPTION () { return config.get<string>('instance.description') },
|
|
|
|
get TERMS () { return config.get<string>('instance.terms') },
|
2019-08-23 15:23:27 +02:00
|
|
|
get CODE_OF_CONDUCT () { return config.get<string>('instance.code_of_conduct') },
|
|
|
|
|
2019-09-03 09:49:04 +02:00
|
|
|
get CREATION_REASON () { return config.get<string>('instance.creation_reason') },
|
|
|
|
|
2019-08-23 15:23:27 +02:00
|
|
|
get MODERATION_INFORMATION () { return config.get<string>('instance.moderation_information') },
|
|
|
|
get ADMINISTRATOR () { return config.get<string>('instance.administrator') },
|
|
|
|
get MAINTENANCE_LIFETIME () { return config.get<string>('instance.maintenance_lifetime') },
|
|
|
|
get BUSINESS_MODEL () { return config.get<string>('instance.business_model') },
|
2019-09-05 09:43:35 +02:00
|
|
|
get HARDWARE_INFORMATION () { return config.get<string>('instance.hardware_information') },
|
2019-08-23 15:23:27 +02:00
|
|
|
|
|
|
|
get LANGUAGES () { return config.get<string[]>('instance.languages') || [] },
|
|
|
|
get CATEGORIES () { return config.get<number[]>('instance.categories') || [] },
|
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') },
|
|
|
|
get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
|
2021-01-26 01:53:13 +01:00
|
|
|
|
|
|
|
get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
|
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
CUSTOMIZATIONS: {
|
|
|
|
get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') },
|
|
|
|
get CSS () { return config.get<string>('instance.customizations.css') }
|
|
|
|
},
|
|
|
|
get ROBOTS () { return config.get<string>('instance.robots') },
|
|
|
|
get SECURITYTXT () { return config.get<string>('instance.securitytxt') },
|
|
|
|
get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') }
|
|
|
|
},
|
|
|
|
SERVICES: {
|
|
|
|
TWITTER: {
|
|
|
|
get USERNAME () { return config.get<string>('services.twitter.username') },
|
|
|
|
get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
FOLLOWERS: {
|
|
|
|
INSTANCE: {
|
|
|
|
get ENABLED () { return config.get<boolean>('followers.instance.enabled') },
|
|
|
|
get MANUAL_APPROVAL () { return config.get<boolean>('followers.instance.manual_approval') }
|
|
|
|
}
|
2019-07-09 11:45:19 +02:00
|
|
|
},
|
2019-08-30 16:50:12 +02:00
|
|
|
FOLLOWINGS: {
|
|
|
|
INSTANCE: {
|
|
|
|
AUTO_FOLLOW_BACK: {
|
|
|
|
get ENABLED () {
|
|
|
|
return config.get<boolean>('followings.instance.auto_follow_back.enabled')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
AUTO_FOLLOW_INDEX: {
|
|
|
|
get ENABLED () {
|
|
|
|
return config.get<boolean>('followings.instance.auto_follow_index.enabled')
|
|
|
|
},
|
|
|
|
get INDEX_URL () {
|
|
|
|
return config.get<string>('followings.instance.auto_follow_index.index_url')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-07-09 11:45:19 +02:00
|
|
|
THEME: {
|
|
|
|
get DEFAULT () { return config.get<string>('theme.default') }
|
2020-05-28 11:15:38 +02:00
|
|
|
},
|
|
|
|
BROADCAST_MESSAGE: {
|
|
|
|
get ENABLED () { return config.get<boolean>('broadcast_message.enabled') },
|
|
|
|
get MESSAGE () { return config.get<string>('broadcast_message.message') },
|
|
|
|
get LEVEL () { return config.get<BroadcastMessageLevel>('broadcast_message.level') },
|
|
|
|
get DISMISSABLE () { return config.get<boolean>('broadcast_message.dismissable') }
|
2020-05-29 16:16:24 +02:00
|
|
|
},
|
|
|
|
SEARCH: {
|
|
|
|
REMOTE_URI: {
|
2021-02-01 11:30:01 +01:00
|
|
|
get USERS () { return config.get<boolean>('search.remote_uri.users') },
|
|
|
|
get ANONYMOUS () { return config.get<boolean>('search.remote_uri.anonymous') }
|
2020-05-29 16:16:24 +02:00
|
|
|
},
|
|
|
|
SEARCH_INDEX: {
|
|
|
|
get ENABLED () { return config.get<boolean>('search.search_index.enabled') },
|
|
|
|
get URL () { return config.get<string>('search.search_index.url') },
|
|
|
|
get DISABLE_LOCAL_SEARCH () { return config.get<boolean>('search.search_index.disable_local_search') },
|
|
|
|
get IS_DEFAULT_SEARCH () { return config.get<boolean>('search.search_index.is_default_search') }
|
|
|
|
}
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
2022-08-10 09:53:39 +02:00
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function registerConfigChangedHandler (fun: Function) {
|
|
|
|
configChangedHandlers.push(fun)
|
|
|
|
}
|
|
|
|
|
2020-02-17 10:27:00 +01:00
|
|
|
function isEmailEnabled () {
|
2021-01-26 09:28:28 +01:00
|
|
|
if (CONFIG.SMTP.TRANSPORT === 'sendmail' && CONFIG.SMTP.SENDMAIL) return true
|
|
|
|
|
|
|
|
if (CONFIG.SMTP.TRANSPORT === 'smtp' && CONFIG.SMTP.HOSTNAME && CONFIG.SMTP.PORT) return true
|
|
|
|
|
|
|
|
return false
|
2020-02-17 10:27:00 +01:00
|
|
|
}
|
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
CONFIG,
|
2020-02-17 10:27:00 +01:00
|
|
|
registerConfigChangedHandler,
|
|
|
|
isEmailEnabled
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function getLocalConfigFilePath () {
|
2021-10-12 13:33:44 +02:00
|
|
|
const localConfigDir = getLocalConfigDir()
|
2019-04-11 11:33:44 +02:00
|
|
|
|
|
|
|
let filename = 'local'
|
|
|
|
if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}`
|
|
|
|
if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`
|
|
|
|
|
2021-10-12 13:33:44 +02:00
|
|
|
return join(localConfigDir, filename + '.json')
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLocalConfigDir () {
|
|
|
|
if (process.env.PEERTUBE_LOCAL_CONFIG) return process.env.PEERTUBE_LOCAL_CONFIG
|
|
|
|
|
|
|
|
const configSources = config.util.getConfigSources()
|
|
|
|
if (configSources.length === 0) throw new Error('Invalid config source.')
|
|
|
|
|
|
|
|
return dirname(configSources[0].name)
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
|
2020-01-10 10:11:28 +01:00
|
|
|
function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
|
2019-04-11 11:33:44 +02:00
|
|
|
if (!objs) return []
|
|
|
|
|
|
|
|
if (!Array.isArray(objs)) return objs
|
|
|
|
|
|
|
|
return objs.map(obj => {
|
|
|
|
return Object.assign({}, obj, {
|
2019-04-11 15:38:53 +02:00
|
|
|
minLifetime: parseDurationToMs(obj.min_lifetime),
|
2019-04-11 11:33:44 +02:00
|
|
|
size: bytes.parse(obj.size),
|
|
|
|
minViews: obj.min_views
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reloadConfig () {
|
|
|
|
|
2021-10-12 13:33:44 +02:00
|
|
|
function getConfigDirectories () {
|
2019-04-11 11:33:44 +02:00
|
|
|
if (process.env.NODE_CONFIG_DIR) {
|
2021-10-14 11:35:43 +02:00
|
|
|
return process.env.NODE_CONFIG_DIR.split(':')
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
|
2021-10-12 13:33:44 +02:00
|
|
|
return [ join(root(), 'config') ]
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function purge () {
|
2021-10-12 13:33:44 +02:00
|
|
|
const directories = getConfigDirectories()
|
2021-04-09 09:37:46 +02:00
|
|
|
|
2019-04-11 11:33:44 +02:00
|
|
|
for (const fileName in require.cache) {
|
2021-10-12 13:33:44 +02:00
|
|
|
if (directories.some((dir) => fileName.includes(dir)) === false) {
|
2019-04-11 11:33:44 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
delete require.cache[fileName]
|
|
|
|
}
|
|
|
|
|
2021-12-03 09:52:03 +01:00
|
|
|
decacheModule('config')
|
2019-04-11 11:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
purge()
|
|
|
|
|
|
|
|
config = require('config')
|
|
|
|
|
|
|
|
for (const configChangedHandler of configChangedHandlers) {
|
|
|
|
configChangedHandler()
|
|
|
|
}
|
|
|
|
}
|