forked from vernemq/vernemq
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvmq_diversity.schema
More file actions
479 lines (410 loc) · 18.9 KB
/
vmq_diversity.schema
File metadata and controls
479 lines (410 loc) · 18.9 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
%% -*- mode: erlang -*-
%% ex: ft=erlang
%% @doc Enable to keep the Lua state between calls. This would allow to
%% to set global variables and reuse them in a later callback call or
%% even in a different callback. Default is 'off' enabling that no Lua
%% garbage collection is triggered.
%% Scripts can override this configuration by setting `keep_state = true`
%% global variable in Lua script
{mapping, "vmq_diversity.keep_state", "vmq_diversity.keep_state", [
{default, off},
{datatype, flag},
hidden
]}.
%% @doc Configures the number of parallel Lua states that are used for the
%% same script. This can be useful for load balancing. Defaults to 1.
%% Scripts can override this configuration by setting `num_states = 10`
%% global variable in Lua script.
{mapping, "vmq_diversity.nr_lua_states", "vmq_diversity.nr_lua_states", [
{default, 1},
{datatype, integer},
hidden
]}.
%% @doc Configure the vmq_diversity plugin script dir. The script dir
%% is searched for Lua scripts which are automatically loaded when the
%% plugin is enabled.
{mapping, "vmq_diversity.script_dir", "vmq_diversity.script_dir", [
{default, "{{platform_share_dir}}/lua"},
{datatype, directory}
]}.
{mapping, "vmq_diversity.auth_postgres.enabled", "vmq_diversity.auth_cache.postgres.enabled",
[{datatype, flag},
{default, off}]}.
{mapping, "vmq_diversity.auth_postgres.script", "vmq_diversity.auth_cache.postgres.file",
[{datatype, file},
{default, "{{platform_share_dir}}/lua/auth/postgres.lua"},
hidden
]}.
{mapping, "vmq_diversity.postgres.host", "vmq_diversity.db_config.postgres.host",
[{datatype, string},
{default, "localhost"},
{commented, "localhost"}]}.
{mapping, "vmq_diversity.postgres.port", "vmq_diversity.db_config.postgres.port",
[{datatype, integer},
{default, 5432},
{commented, 5432}]}.
{mapping, "vmq_diversity.postgres.user", "vmq_diversity.db_config.postgres.user",
[{datatype, string},
{default, "root"},
{commented, "root"}]}.
{mapping, "vmq_diversity.postgres.password", "vmq_diversity.db_config.postgres.password",
[{datatype, string},
{default, "password"},
{commented, "password"}]}.
{mapping, "vmq_diversity.postgres.database", "vmq_diversity.db_config.postgres.database",
[{datatype, string},
{default, "vernemq_db"},
{commented, "vernemq_db"}]}.
{mapping, "vmq_diversity.postgres.pool_size", "vmq_diversity.db_config.postgres.pool_size",
[{datatype, integer},
{default, 5},
hidden]}.
%% @doc Specify if the postgresql driver should use TLS or not.
{mapping, "vmq_diversity.postgres.ssl", "vmq_diversity.db_config.postgres.ssl",
[{datatype, flag},
{default, off}
]}.
%% @doc The cafile is used to define the path to a file containing
%% the PEM encoded CA certificates that are trusted.
{mapping, "vmq_diversity.postgres.cafile", "vmq_diversity.db_config.postgres.cacertfile",
[
{default, ""},
{datatype, file},
{commented, "{{platform_etc_dir}}/cafile.pem"},
{validators, ["file-exists", "file-is-readable"]}
]}.
%% @doc Set the path to the PEM encoded server certificate.
{mapping, "vmq_diversity.postgres.certfile", "vmq_diversity.db_config.postgres.certfile",
[
{default, ""},
{datatype, file},
{validators, ["file-exists", "file-is-readable"]},
{commented, "{{platform_etc_dir}}/cert.pem"}
]}.
%% @doc Set the path to the PEM encoded key file.
{mapping, "vmq_diversity.postgres.keyfile", "vmq_diversity.db_config.postgres.keyfile",
[
{default, ""},
{datatype, file},
{validators, ["file-exists", "file-is-readable"]},
{commented, "{{platform_etc_dir}}/keyfile.pem"}
]}.
%% @doc Setting the depth for CA chains
{mapping, "vmq_diversity.postgres.ssl.depth", "vmq_diversity.db_config.postgres.depth", [
{default, 3},
{datatype, integer},
hidden
]}.
%% @doc Allow the plugin to open SSL connections to remote DB with wildcard certs
{mapping, "vmq_diversity.postgres.ssl.customize_hostname_check", "vmq_diversity.db_config.postgres.customize_hostname_check", [
{datatype, {enum, ['https']}},
{default, 'https'},
{commented, on}
]}.
%% @doc Whether the client verifies the server cert or not.
%% Use "verify_peer" in production.
{mapping, "vmq_diversity.postgres.ssl.verify", "vmq_diversity.db_config.postgres.verify", [
{default, 'verify_peer'},
{datatype, {enum, ['verify_none',
'verify_peer']}}
]}.
%% @doc Whether to use the System CAs (public_key:cacerts_get/0).
%% Can be used as an alternative to provide a CAcertfile
{mapping, "vmq_diversity.postgres.ssl.use_system_cas", "vmq_diversity.db_config.postgres.use_system_cas", [
{default, on},
{datatype, flag}
]}.
%% @doc The password hashing method to use in PostgreSQL:
{mapping, "vmq_diversity.postgres.password_hash_method", "vmq_diversity.db_config.postgres.password_hash_method",
[{datatype, {enum, [crypt, bcrypt]}},
{default, crypt}
]}.
{mapping, "vmq_diversity.auth_cockroachdb.enabled", "vmq_diversity.auth_cache.cockroachdb.enabled",
[{datatype, flag},
{default, off}]}.
{mapping, "vmq_diversity.auth_cockroachdb.script", "vmq_diversity.auth_cache.cockroachdb.file",
[{datatype, file},
{default, "{{platform_share_dir}}/lua/auth/cockroachdb.lua"},
hidden
]}.
{mapping, "vmq_diversity.cockroachdb.host", "vmq_diversity.db_config.cockroachdb.host",
[{datatype, string},
{default, "localhost"},
{commented, "localhost"}]}.
{mapping, "vmq_diversity.cockroachdb.port", "vmq_diversity.db_config.cockroachdb.port",
[{datatype, integer},
{default, 5432},
{commented, 5432}]}.
{mapping, "vmq_diversity.cockroachdb.user", "vmq_diversity.db_config.cockroachdb.user",
[{datatype, string},
{default, "root"},
{commented, "root"}]}.
{mapping, "vmq_diversity.cockroachdb.password", "vmq_diversity.db_config.cockroachdb.password",
[{datatype, string},
{default, "password"},
{commented, "password"}]}.
{mapping, "vmq_diversity.cockroachdb.database", "vmq_diversity.db_config.cockroachdb.database",
[{datatype, string},
{default, "vernemq_db"},
{commented, "vernemq_db"}]}.
{mapping, "vmq_diversity.cockroachdb.pool_size", "vmq_diversity.db_config.cockroachdb.pool_size",
[{datatype, integer},
{default, 5},
hidden]}.
%% @doc Specify if the cockroachdb driver should use TLS or not.
{mapping, "vmq_diversity.cockroachdb.ssl", "vmq_diversity.db_config.cockroachdb.ssl",
[{datatype, flag},
{default, on}
]}.
%% @doc The cafile is used to define the path to a file containing
%% the PEM encoded CA certificates that are trusted.
{mapping, "vmq_diversity.cockroachdb.cafile", "vmq_diversity.db_config.cockroachdb.cacertfile",
[
{default, ""},
{datatype, file},
{commented, "{{platform_etc_dir}}/cafile.pem"},
{validators, ["file-exists", "file-is-readable"]}
]}.
%% @doc Set the path to the PEM encoded server certificate.
{mapping, "vmq_diversity.cockroachdb.certfile", "vmq_diversity.db_config.cockroachdb.certfile",
[
{default, ""},
{datatype, file},
{validators, ["file-exists", "file-is-readable"]},
{commented, "{{platform_etc_dir}}/cert.pem"}
]}.
%% @doc Set the path to the PEM encoded key file.
{mapping, "vmq_diversity.cockroachdb.keyfile", "vmq_diversity.db_config.cockroachdb.keyfile",
[
{default, ""},
{datatype, file},
{validators, ["file-exists", "file-is-readable"]},
{commented, "{{platform_etc_dir}}/keyfile.pem"}
]}.
%% @doc Setting the depth for CA chains
{mapping, "vmq_diversity.cockroachdb.ssl.depth", "vmq_diversity.db_config.cockroachdb.depth", [
{default, 3},
{datatype, integer},
hidden
]}.
%% @doc Allow the plugin to open SSL connections to remote DB with wildcard certs
{mapping, "vmq_diversity.cockroachdb.ssl.customize_hostname_check", "vmq_diversity.db_config.cockroachdb.customize_hostname_check", [
{datatype, {enum, ['https']}},
{default, 'https'},
{commented, on}
]}.
%% @doc Whether the client verifies the server cert or not.
%% Use "verify_peer" in production.
{mapping, "vmq_diversity.cockroachdb.ssl.verify", "vmq_diversity.db_config.cockroachdb.verify", [
{default, 'verify_peer'},
{datatype, {enum, ['verify_none',
'verify_peer']}}
]}.
%% @doc Whether to use the System CAs (public_key:cacerts_get/0).
%% Can be used as an alternative to provide a CAcertfile
{mapping, "vmq_diversity.cockroachdb.ssl.use_system_cas", "vmq_diversity.db_config.cockroachdb.use_system_cas", [
{default, on},
{datatype, flag}
]}.
%% @doc The password hashing method to use in CockroachDB:
{mapping, "vmq_diversity.cockroachdb.password_hash_method", "vmq_diversity.db_config.cockroachdb.password_hash_method",
[{datatype, {enum, [sha256, bcrypt]}},
{default, bcrypt}
]}.
{mapping, "vmq_diversity.auth_mysql.enabled", "vmq_diversity.auth_cache.mysql.enabled",
[{datatype, flag},
{default, off}]}.
{mapping, "vmq_diversity.auth_mysql.script", "vmq_diversity.auth_cache.mysql.file",
[{datatype, file},
{default, "{{platform_share_dir}}/lua/auth/mysql.lua"},
hidden
]}.
{mapping, "vmq_diversity.mysql.host", "vmq_diversity.db_config.mysql.host",
[{datatype, string},
{default, "localhost"},
{commented, "localhost"}]}.
{mapping, "vmq_diversity.mysql.port", "vmq_diversity.db_config.mysql.port",
[{datatype, integer},
{default, 3306},
{commented, 3306}]}.
{mapping, "vmq_diversity.mysql.user", "vmq_diversity.db_config.mysql.user",
[{datatype, string},
{default, "root"},
{commented, "root"}]}.
{mapping, "vmq_diversity.mysql.password", "vmq_diversity.db_config.mysql.password",
[{datatype, string},
{default, "password"},
{commented, "password"}]}.
{mapping, "vmq_diversity.mysql.database", "vmq_diversity.db_config.mysql.database",
[{datatype, string},
{default, "vernemq_db"},
{commented, "vernemq_db"}]}.
{mapping, "vmq_diversity.mysql.pool_size", "vmq_diversity.db_config.mysql.pool_size",
[{datatype, integer},
{default, 5},
hidden]}.
%% @doc The password hashing method to use in MySQL:
%% password: Default for compatibility, deprecated since MySQL 5.7.6 and not
%% usable with MySQL 8.0.11+.
%% Docs: https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_password
%% md5: Calculates an MD5 128-bit checksum of the password.
%% Docs: https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5
%% sha1: Calculates the SHA-1 160-bit checksum for the password.
%% Docs: https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1
%% sha256: Calculates the SHA-2 hash of the password, using 256 bits.
%% Works only if MySQL has been configured with SSL support.
%% Docs: https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha2
{mapping, "vmq_diversity.mysql.password_hash_method", "vmq_diversity.db_config.mysql.password_hash_method",
[{datatype, {enum, [password, md5, sha1, sha256]}},
{default, password}
]}.
{mapping, "vmq_diversity.auth_mongodb.enabled", "vmq_diversity.auth_cache.mongodb.enabled",
[{datatype, flag},
{default, off}]}.
{mapping, "vmq_diversity.auth_mongodb.script", "vmq_diversity.auth_cache.mongodb.file",
[{datatype, file},
{default, "{{platform_share_dir}}/lua/auth/mongodb.lua"},
hidden
]}.
{mapping, "vmq_diversity.mongodb.host", "vmq_diversity.db_config.mongodb.host",
[{datatype, string},
{default, "localhost"},
{commented, "localhost"}]}.
{mapping, "vmq_diversity.mongodb.port", "vmq_diversity.db_config.mongodb.port",
[{datatype, integer},
{default, 27017},
{commented, 27017}]}.
{mapping, "vmq_diversity.mongodb.login", "vmq_diversity.db_config.mongodb.login",
[{datatype, string},
{default, undefined},
{commented, ""}]}.
{mapping, "vmq_diversity.mongodb.password", "vmq_diversity.db_config.mongodb.password",
[{datatype, string},
{default, undefined},
{commented, ""}]}.
{mapping, "vmq_diversity.mongodb.database", "vmq_diversity.db_config.mongodb.database",
[{datatype, string},
{default, undefined},
{commented, ""}]}.
{mapping, "vmq_diversity.mongodb.pool_size", "vmq_diversity.db_config.mongodb.pool_size",
[{datatype, integer},
{default, 5},
hidden]}.
{mapping, "vmq_diversity.mongodb.r_mode", "vmq_diversity.db_config.mongodb.r_mode",
[{datatype, atom},
{default, master},
hidden]}.
{mapping, "vmq_diversity.mongodb.w_mode", "vmq_diversity.db_config.mongodb.w_mode",
[{datatype, atom},
{default, safe},
hidden]}.
%% @doc Specify if the mongodb driver should use TLS or not.
{mapping, "vmq_diversity.mongodb.ssl", "vmq_diversity.db_config.mongodb.ssl",
[{datatype, flag},
{default, off}
]}.
%% @doc The cafile is used to define the path to a file containing
%% the PEM encoded CA certificates that are trusted.
{mapping, "vmq_diversity.mongodb.cafile", "vmq_diversity.db_config.mongodb.cacertfile",
[
{default, ""},
{datatype, file},
{commented, "{{platform_etc_dir}}/cafile.pem"},
{validators, ["file-exists", "file-is-readable"]}
]}.
%% @doc Set the path to the PEM encoded server certificate.
{mapping, "vmq_diversity.mongodb.certfile", "vmq_diversity.db_config.mongodb.certfile",
[
{default, ""},
{datatype, file},
{validators, ["file-exists", "file-is-readable"]},
{commented, "{{platform_etc_dir}}/cert.pem"}
]}.
%% @doc Set the path to the PEM encoded key file.
{mapping, "vmq_diversity.mongodb.keyfile", "vmq_diversity.db_config.mongodb.keyfile",
[
{default, ""},
{datatype, file},
{validators, ["file-exists", "file-is-readable"]},
{commented, "{{platform_etc_dir}}/keyfile.pem"}
]}.
{mapping, "vmq_diversity.auth_redis.enabled", "vmq_diversity.auth_cache.redis.enabled",
[{datatype, flag},
{default, off}]}.
{mapping, "vmq_diversity.auth_redis.script", "vmq_diversity.auth_cache.redis.file",
[{datatype, file},
{default, "{{platform_share_dir}}/lua/auth/redis.lua"},
hidden
]}.
{mapping, "vmq_diversity.redis.host", "vmq_diversity.db_config.redis.host",
[{datatype, string},
{default, "localhost"},
{commented, "localhost"}]}.
{mapping, "vmq_diversity.redis.port", "vmq_diversity.db_config.redis.port",
[{datatype, integer},
{default, 6379},
{commented, 6379}]}.
{mapping, "vmq_diversity.redis.password", "vmq_diversity.db_config.redis.password",
[{datatype, string},
{default, ""},
{commented, ""}]}.
{mapping, "vmq_diversity.redis.database", "vmq_diversity.db_config.redis.database",
[{datatype, integer},
{default, 0},
{commented, 0}]}.
{mapping, "vmq_diversity.redis.pool_size", "vmq_diversity.db_config.redis.pool_size",
[{datatype, integer},
{default, 5},
hidden]}.
{mapping, "vmq_diversity.memcache.host", "vmq_diversity.db_config.memcache.host",
[{datatype, string},
{default, "localhost"},
{commented, "localhost"}]}.
{mapping, "vmq_diversity.memcache.port", "vmq_diversity.db_config.memcache.port",
[{datatype, integer},
{default, 11211},
{commented, 11211}]}.
%% @doc vmq_diversity.<name>.file = <file> loads a specific lua
%% script when `vmq_diversity` starts. The scripts are loaded in the
%% order defined by the names given, i.e., the script with <name>
%% 'script1' is started before the plugin with <name> 'script2'.
%%
%%
%% Scripts loaded like this are loaded after the scripts in the
%% default script dir.
%%
{mapping, "vmq_diversity.$script.file", "vmq_diversity.user_scripts", [
{datatype, file},
{commented, "path/to/my/script.lua"},
{include_default, "script1"}
]}.
{translation,
"vmq_diversity.user_scripts",
fun(Conf) ->
ScriptNames =
proplists:get_all_values(
"$script",
cuttlefish_variable:fuzzy_matches(["vmq_diversity", "$script", "file"], Conf)),
Scripts =
[ {SortName, cuttlefish:conf_get("vmq_diversity." ++ SortName ++ ".file", Conf, undefined)}
|| SortName <- ScriptNames ],
lists:keysort(1, Scripts)
end}.
{mapping, "vmq_diversity.clique_lead_line", "vmq_diversity.clique_lead_line",
[{datatype, string},
hidden,
{default, " script Manage lua scripts\n"}]}.
{validator, "file-exists", "file does not exist",
fun("") ->
%% "" is used as the default value in most places, we should
%% not error out because of that.
true;
(Name) -> vmq_schema_util:file_exists(Name)
end}.
{validator, "file-is-readable", "file is not readable, check permissions",
fun("") ->
%% "" is used as the default value in most places, we should
%% not error out because of that.
true;
(Name) -> vmq_schema_util:file_is_readable(Name)
end}.