File size: 1,898 Bytes
5bab120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { getVersion } from "@imput/version-info";
import { services } from "./processing/service-config.js";

const version = await getVersion();

const disabledServices = process.env.DISABLED_SERVICES?.split(',') || [];
const enabledServices = new Set(Object.keys(services).filter(e => {
    if (!disabledServices.includes(e)) {
        return e;
    }
}));

const env = {
    apiURL: process.env.API_URL || '',
    apiPort: process.env.API_PORT || 9000,

    listenAddress: process.env.API_LISTEN_ADDRESS,
    freebindCIDR: process.platform === 'linux' && process.env.FREEBIND_CIDR,

    corsWildcard: process.env.CORS_WILDCARD !== '0',
    corsURL: process.env.CORS_URL,

    cookiePath: process.env.COOKIE_PATH,

    rateLimitWindow: (process.env.RATELIMIT_WINDOW && parseInt(process.env.RATELIMIT_WINDOW)) || 60,
    rateLimitMax: (process.env.RATELIMIT_MAX && parseInt(process.env.RATELIMIT_MAX)) || 20,

    durationLimit: (process.env.DURATION_LIMIT && parseInt(process.env.DURATION_LIMIT)) || 10800,
    streamLifespan: 90,

    processingPriority: process.platform !== 'win32'
        && process.env.PROCESSING_PRIORITY
        && parseInt(process.env.PROCESSING_PRIORITY),

    externalProxy: process.env.API_EXTERNAL_PROXY,

    turnstileSitekey: process.env.TURNSTILE_SITEKEY,
    turnstileSecret: process.env.TURNSTILE_SECRET,
    jwtSecret: process.env.JWT_SECRET,
    jwtLifetime: process.env.JWT_EXPIRY || 120,

    sessionEnabled: process.env.TURNSTILE_SITEKEY
                        && process.env.TURNSTILE_SECRET
                        && process.env.JWT_SECRET,

    enabledServices,
}

const genericUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";
const cobaltUserAgent = `cobalt/${version} (+https://github.com/imputnet/cobalt)`;

export {
    env,
    genericUserAgent,
    cobaltUserAgent,
}