-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
144 lines (117 loc) · 6.18 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
// Database Details
$database['server'] = getEnvOrDefault('DB_SERVER', 'localhost');
$database['type'] = getEnvOrDefault('DB_SERVER_TYPE', 'mysql');
$database['username'] = getEnvOrDefault('DB_SERVER_USERNAME', 'dnsapi');
$database['password'] = getEnvOrDefault('DB_SERVER_PASSWORD', 'dnsapi');
$database['database'] = getEnvOrDefault('DB_SERVER_DATABASE', 'dnsapi');
// Secret for JWT Tokens
// Must be at least 12 characters in length, contain upper and lower case
// letters, a number, and a special character `*&!@%^#$``
$config['jwtsecret'] = getEnvOrDefault('JWT_SECRET', 'S0M3SEcr3t!#');
// Config for redis.
//
// This will be used for sessions and by job workers for locking.
$config['redis'] = getEnvOrDefault('REDIS_HOST', '');
$config['redisPort'] = getEnvOrDefault('REDIS_PORT', 6379);
$config['redisSessionPrefix'] = getEnvOrDefault('REDIS_SESSION_PREFIX', 'MyDNSHost-API-Session');
// Config for Site registration
$config['register_enabled'] = parseBool(getEnvOrDefault('ALLOW_REGISTER', 'true'));
$config['register_manual_verify'] = parseBool(getEnvOrDefault('REGISTER_MANUAL_VERIFY', 'false'));
$config['register_permissions'] = explode(',', getEnvOrDefault('REGISTER_PERMISSIONS', 'domains_create'));
$config['register_require_terms'] = parseBool(getEnvOrDefault('REGISTER_REQUIRE_TERMS', 'true'));
// Configuration for YUBIKEY Authentication
$config['twofactor']['yubikey']['clientid'] = '12345';
$config['twofactor']['yubikey']['secret'] = 'FOOBAR=';
$config['twofactor']['yubikey']['enabled'] = false;
// Configuration for AUTHY Authentication
$config['twofactor']['authy']['clientid'] = '12345';
$config['twofactor']['authy']['secret'] = 'FOOBAR=';
$config['twofactor']['authy']['enabled'] = false;
// Minimum terms time required to be considered "accepted".
//
// If this is not met, /userdata responses will show `"acceptterms": false`
// and the frontend will prompt the user to accept the terms before
// continuing.
$config['minimum_terms_time'] = (int)getEnvOrDefault('TERMS_TIME', 1528752008);
// Minimum terms time required to be able to use all API functions.
//
// This should be earlier than `minimum_terms_time` to allow API functions
// to still work for a limited time after a change of terms (Users who have
// never accepted the terms have a time of -1)
//
// If the terms are not accepted after this time then only `user_read` and
// `user_write` permissions will be granted to a user logging in.
//
// This does not impact DomainKeys
$config['api_minimum_terms_time'] = (int)getEnvOrDefault('API_TERMS_TIME', -2);
// Allow users to delete their own account.
$config['self_delete'] = parseBool(getEnvOrDefault('ALLOW_SELF_DELETE', 'true'));
// General details (used by emails)
$config['sitename'] = getEnvOrDefault('SITE_NAME', 'MyDNSHost');
$config['siteurl'] = getEnvOrDefault('SITE_URL', 'https://mydnshost.co.uk/');
// Template details (used by emails)
$config['templates']['dir'] = getEnvOrDefault('TEMPLATE_DIR', __DIR__ . '/templates');
$config['templates']['theme'] = getEnvOrDefault('TEMPLATE_THEME', 'default');
$config['templates']['cache'] = getEnvOrDefault('TEMPLATE_CACHE', __DIR__ . '/templates_c');
// Config for email sending
$config['email']['enabled'] = parseBool(getEnvOrDefault('EMAIL_ENABLED', 'false'));
$config['email']['server'] = getEnvOrDefault('EMAIL_SERVER', '');
$config['email']['username'] = getEnvOrDefault('EMAIL_USERNAME', '');
$config['email']['password'] = getEnvOrDefault('EMAIL_PASSWORD', '');
$config['email']['from'] = getEnvOrDefault('EMAIL_FROM', '[email protected]');
$config['email']['from_name'] = getEnvOrDefault('EMAIL_FROM_NAME', $config['sitename']);
// Config for RabbitMQ
$config['rabbitmq']['host'] = getEnvOrDefault('RABBITMQ_HOST', '127.0.0.1');
$config['rabbitmq']['port'] = getEnvOrDefault('RABBITMQ_PORT', 5672);
$config['rabbitmq']['user'] = getEnvOrDefault('RABBITMQ_USER', 'guest');
$config['rabbitmq']['pass'] = getEnvOrDefault('RABBITMQ_PASS', 'guest');
// Config for MongoDB
$config['mongodb']['server'] = getEnvOrDefault('MONGO_HOST', '127.0.0.1');
$config['mongodb']['database'] = getEnvOrDefault('MONGO_DB', 'mydnshost');
function getJobWorkerConfig($w) {
$result = [];
$result['processes'] = getEnvOrDefault('WORKER_' . $w . '_PROCESSES', getEnvOrDefault('WORKER_PROCESSES', 1));
$result['maxJobs'] = getEnvOrDefault('WORKER_' . $w . '_MAXJOBS', getEnvOrDefault('WORKER_MAXJOBS', 250));
return $result;
}
function getJobWorkers($workerList) {
$result = [];
foreach (explode(',', $workerList) as $w) {
if (empty($w)) { continue; }
$includeWorker = true;
if ($w[0] == '-') { $w = substr($w, 1); $includeWorker = false; }
if ($w == '*') {
foreach (recursiveFindFiles(__DIR__ . '/workers/workers') as $file) {
$w = pathinfo($file, PATHINFO_FILENAME);
$result[$w] = getJobWorkerConfig($w);
$result[$w]['include'] = $includeWorker;
}
} else {
$result[$w] = getJobWorkerConfig($w);
$result[$w]['include'] = $includeWorker;
}
}
return $result;
}
$config['jobworkers'] = getJobWorkers(getEnvOrDefault('WORKER_WORKERS', ''));
// Default DNS Records
$config['defaultRecords'] = [];
$config['defaultRecords'][] = ['name' => '', 'type' => 'NS', 'content' => 'ns1.example.com'];
$config['defaultRecords'][] = ['name' => '', 'type' => 'NS', 'content' => 'ns2.example.com'];
$config['defaultRecords'][] = ['name' => '', 'type' => 'NS', 'content' => 'ns3.example.com'];
// Default SOA
$config['defaultSOA'] = ['primaryNS' => 'ns1.example.com.'];
// Influx DB
$config['influx']['host'] = getEnvOrDefault('INFLUX_HOST', 'localhost');
$config['influx']['port'] = getEnvOrDefault('INFLUX_PORT', '8086');
$config['influx']['user'] = getEnvOrDefault('INFLUX_USER', '');
$config['influx']['pass'] = getEnvOrDefault('INFLUX_PASS', '');
$config['influx']['db'] = getEnvOrDefault('INFLUX_DB', 'MyDNSHost');
// Domain Logs Source
// $config['domainlogs']['source'] = getEnvOrDefault('DOMAINLOGS_SOURCE', 'file:/var/log/bind.log');
$config['domainlogs']['source'] = getEnvOrDefault('DOMAINLOGS_SOURCE', 'docker:bind');
// Local configuration.
if (file_exists(dirname(__FILE__) . '/config.local.php')) {
include(dirname(__FILE__) . '/config.local.php');
}