1/*
2 This file is part of MTProto-Server
3
4 MTProto-Server is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 MTProto-Server is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with MTProto-Server. If not, see <http://www.gnu.org/licenses/>.
16
17 This program is released under the GPL with the additional exemption
18 that compiling, linking, and/or using OpenSSL is allowed.
19 You are free to remove this exemption from derived works.
20
21 Copyright 2012-2018 Nikolai Durov
22 2012-2014 Andrey Lopatin
23 2014-2018 Telegram Messenger Inc
24*/
25#pragma once
26
27#define MAX_CFG_CLUSTERS 1024
28#define MAX_CFG_TARGETS 4096
29#define MAX_CLUSTER_TARGETS 1024
30
31struct mf_cluster {
32 int targets_num; // 1 for old-fashioned
33 int write_targets_num;
34 int targets_allocated; // size of `cluster_targets` and `balance_hashes` arrays
35 int flags;
36 int cluster_id; // datacenter # or 0
37 conn_target_job_t *cluster_targets; // N entries
38};
39
40struct mf_group_stats {
41 int tot_clusters;
42};
43
44struct mf_config {
45 int tot_targets;
46 int auth_clusters, default_cluster_id;
47 int min_connections, max_connections;
48 double timeout;
49 int config_bytes, config_loaded_at;
50 char *config_md5_hex;
51 struct mf_group_stats auth_stats;
52 int have_proxy;
53 struct mf_cluster *default_cluster;
54 conn_target_job_t targets[MAX_CFG_TARGETS];
55 struct mf_cluster auth_cluster[MAX_CFG_CLUSTERS];
56 // struct mf_cluster *clusters_by_hash[MAX_CFG_CLUSTERS*2];
57};
58
59extern struct mf_config *CurConf;
60extern char *config_filename;
61
62extern struct conn_target_info default_cfg_ct;
63extern int default_cfg_min_connections, default_cfg_max_connections;
64
65// (re)load configuration file
66
67int do_reload_config (int create_conn);
68
69struct mf_cluster *mf_cluster_lookup (struct mf_config *MC, int cluster_id, int force);
70
71