-
Notifications
You must be signed in to change notification settings - Fork 43
/
config.php
60 lines (56 loc) · 2.26 KB
/
config.php
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
58
59
60
<?php
global $options;
if (
getenv('RPM') === false
|| getenv('ERRORS_LIMIT') === false
|| getenv('CLIENTS_SETTINGS') === false
) {
throw new RuntimeException(
'Please update .env or .env.docker. DEFAULT_RPM, DEFAULT_ERRORS_LIMIT, CLIENTS_SETTINGS required.'
);
}
if (getenv('SERVER_ADDRESS') === false) {
throw new RuntimeException(
'Please update .env or .env.docker. Check .env.example .env.docker.example for changes.'
);
}
$clientsSettings = json_decode(getenv("CLIENTS_SETTINGS"), true, 5, JSON_THROW_ON_ERROR);
if ($options['docker'] && isset($clientsSettings['127.0.0.1'])) {
$localIp = getHostByName(getHostName());
foreach (range(0, 255) as $ipPart) {
$ip = preg_replace('/\.\d*$/', ".{$ipPart}", $localIp);
$clientsSettings[$ip] = &$clientsSettings['127.0.0.1'];
}
}
return [
'url' => (string) getenv('SELF_URL'),
'server' => [
'address' => (string) (getenv('SERVER_ADDRESS') ?? '127.0.0.1'),
'port' => (string) (getenv('SERVER_PORT') ?? '9504'),
'real_ip_header' => (string)(getenv('REAL_IP_HEADER') ?? ''),
],
'client' => [
'address' => (string) (getenv('TELEGRAM_CLIENT_ADDRESS') ?? '127.0.0.1'),
'port' => (string) (getenv('TELEGRAM_CLIENT_PORT') ?? '9503'),
'username' => (string) (getenv('TELEGRAM_CLIENT_USERNAME')),
'password' => (string) (getenv('TELEGRAM_CLIENT_PASSWORD')),
],
'access' => [
'rpm' => (int) getenv('RPM'),
'errors_limit' => (int) getenv('ERRORS_LIMIT'),
'media_rpm' => (int) getenv('MEDIA_RPM'),
'media_errors_limit' => (int) getenv('MEDIA_ERRORS_LIMIT'),
'clients_settings' => $clientsSettings,
'only_public_channels' => (bool) getenv('ONLY_PUBLIC_CHANNELS'),
'forbidden_peer_regex' => (string) getenv('FORBIDDEN_PEER_REGEX'),
'cache_peer_errors_regex' => (string) getenv('CACHE_PEER_ERRORS_REGEX'),
'forbidden_referer_regex' => (string)getenv('FORBIDDEN_REFERERS_REGEX'),
'ip_blacklist' => (string)getenv('IP_BLACKLIST'),
],
'timezone' => (string) getenv('TIMEZONE'),
'log' => [
'dir' => (string) getenv('LOGS_DIR'),
'file' => (string) getenv('LOGS_FILE'),
'level' => (int) getenv('LOGS_LEVEL'),
],
];