diff options
Diffstat (limited to 'other/bootstrap_daemon/src/config.c')
-rw-r--r-- | other/bootstrap_daemon/src/config.c | 400 |
1 files changed, 400 insertions, 0 deletions
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c new file mode 100644 index 00000000..270d399f --- /dev/null +++ b/other/bootstrap_daemon/src/config.c | |||
@@ -0,0 +1,400 @@ | |||
1 | /* config.c | ||
2 | * | ||
3 | * Tox DHT bootstrap daemon. | ||
4 | * | ||
5 | * Copyright (C) 2014-2015 Tox project All Rights Reserved. | ||
6 | * | ||
7 | * This file is part of Tox. | ||
8 | * | ||
9 | * Tox is free software: you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation, either version 3 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * Tox is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "config.h" | ||
25 | |||
26 | #include "config_defaults.h" | ||
27 | #include "log.h" | ||
28 | |||
29 | // C | ||
30 | //#include <stdlib.h> | ||
31 | #include <string.h> | ||
32 | |||
33 | // 3rd party | ||
34 | #include <libconfig.h> | ||
35 | |||
36 | // toxcore | ||
37 | #include "../../bootstrap_node_packets.h" | ||
38 | //#include "../../testing/misc_tools.c" | ||
39 | |||
40 | // Parses tcp relay ports from `cfg` and puts them into `tcp_relay_ports` array | ||
41 | // | ||
42 | // Supposed to be called from get_general_config only | ||
43 | // | ||
44 | // Important: iff `tcp_relay_port_count` > 0, then you are responsible for freeing `tcp_relay_ports` | ||
45 | |||
46 | void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int *tcp_relay_port_count) | ||
47 | { | ||
48 | const char *NAME_TCP_RELAY_PORTS = "tcp_relay_ports"; | ||
49 | |||
50 | *tcp_relay_port_count = 0; | ||
51 | |||
52 | config_setting_t *ports_array = config_lookup(cfg, NAME_TCP_RELAY_PORTS); | ||
53 | |||
54 | if (ports_array == NULL) { | ||
55 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS); | ||
56 | write_log(LOG_LEVEL_WARNING, "Using default '%s':\n", NAME_TCP_RELAY_PORTS); | ||
57 | |||
58 | uint16_t default_ports[DEFAULT_TCP_RELAY_PORTS_COUNT] = {DEFAULT_TCP_RELAY_PORTS}; | ||
59 | |||
60 | int i; | ||
61 | |||
62 | for (i = 0; i < DEFAULT_TCP_RELAY_PORTS_COUNT; i ++) { | ||
63 | write_log(LOG_LEVEL_INFO, "Port #%d: %u\n", i, default_ports[i]); | ||
64 | } | ||
65 | |||
66 | // similar procedure to the one of reading config file below | ||
67 | *tcp_relay_ports = malloc(DEFAULT_TCP_RELAY_PORTS_COUNT * sizeof(uint16_t)); | ||
68 | |||
69 | for (i = 0; i < DEFAULT_TCP_RELAY_PORTS_COUNT; i ++) { | ||
70 | |||
71 | (*tcp_relay_ports)[*tcp_relay_port_count] = default_ports[i]; | ||
72 | |||
73 | if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT | ||
74 | || (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) { | ||
75 | write_log(LOG_LEVEL_WARNING, "Port #%d: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i, | ||
76 | (*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT); | ||
77 | continue; | ||
78 | } | ||
79 | |||
80 | (*tcp_relay_port_count) ++; | ||
81 | } | ||
82 | |||
83 | // the loop above skips invalid ports, so we adjust the allocated memory size | ||
84 | if ((*tcp_relay_port_count) > 0) { | ||
85 | *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); | ||
86 | } else { | ||
87 | free(*tcp_relay_ports); | ||
88 | *tcp_relay_ports = NULL; | ||
89 | } | ||
90 | |||
91 | return; | ||
92 | } | ||
93 | |||
94 | if (config_setting_is_array(ports_array) == CONFIG_FALSE) { | ||
95 | write_log(LOG_LEVEL_ERROR, "'%s' setting should be an array. Array syntax: 'setting = [value1, value2, ...]'.\n", | ||
96 | NAME_TCP_RELAY_PORTS); | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | int config_port_count = config_setting_length(ports_array); | ||
101 | |||
102 | if (config_port_count == 0) { | ||
103 | write_log(LOG_LEVEL_ERROR, "'%s' is empty.\n", NAME_TCP_RELAY_PORTS); | ||
104 | return; | ||
105 | } | ||
106 | |||
107 | *tcp_relay_ports = malloc(config_port_count * sizeof(uint16_t)); | ||
108 | |||
109 | int i; | ||
110 | |||
111 | for (i = 0; i < config_port_count; i ++) { | ||
112 | config_setting_t *elem = config_setting_get_elem(ports_array, i); | ||
113 | |||
114 | if (elem == NULL) { | ||
115 | // it's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be | ||
116 | write_log(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i); | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | if (config_setting_is_number(elem) == CONFIG_FALSE) { | ||
121 | write_log(LOG_LEVEL_WARNING, "Port #%d: Not a number. Skipping.\n", i); | ||
122 | continue; | ||
123 | } | ||
124 | |||
125 | (*tcp_relay_ports)[*tcp_relay_port_count] = config_setting_get_int(elem); | ||
126 | |||
127 | if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT | ||
128 | || (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) { | ||
129 | write_log(LOG_LEVEL_WARNING, "Port #%d: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i, | ||
130 | (*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT); | ||
131 | continue; | ||
132 | } | ||
133 | |||
134 | (*tcp_relay_port_count) ++; | ||
135 | } | ||
136 | |||
137 | // the loop above skips invalid ports, so we adjust the allocated memory size | ||
138 | if ((*tcp_relay_port_count) > 0) { | ||
139 | *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); | ||
140 | } else { | ||
141 | free(*tcp_relay_ports); | ||
142 | *tcp_relay_ports = NULL; | ||
143 | } | ||
144 | } | ||
145 | |||
146 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, int *enable_ipv6, | ||
147 | int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, uint16_t **tcp_relay_ports, | ||
148 | int *tcp_relay_port_count, int *enable_motd, char **motd) | ||
149 | { | ||
150 | config_t cfg; | ||
151 | |||
152 | const char *NAME_PORT = "port"; | ||
153 | const char *NAME_PID_FILE_PATH = "pid_file_path"; | ||
154 | const char *NAME_KEYS_FILE_PATH = "keys_file_path"; | ||
155 | const char *NAME_ENABLE_IPV6 = "enable_ipv6"; | ||
156 | const char *NAME_ENABLE_IPV4_FALLBACK = "enable_ipv4_fallback"; | ||
157 | const char *NAME_ENABLE_LAN_DISCOVERY = "enable_lan_discovery"; | ||
158 | const char *NAME_ENABLE_TCP_RELAY = "enable_tcp_relay"; | ||
159 | const char *NAME_ENABLE_MOTD = "enable_motd"; | ||
160 | const char *NAME_MOTD = "motd"; | ||
161 | |||
162 | config_init(&cfg); | ||
163 | |||
164 | // Read the file. If there is an error, report it and exit. | ||
165 | if (config_read_file(&cfg, cfg_file_path) == CONFIG_FALSE) { | ||
166 | write_log(LOG_LEVEL_ERROR, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg)); | ||
167 | config_destroy(&cfg); | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | // Get port | ||
172 | if (config_lookup_int(&cfg, NAME_PORT, port) == CONFIG_FALSE) { | ||
173 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_PORT); | ||
174 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %d\n", NAME_PORT, DEFAULT_PORT); | ||
175 | *port = DEFAULT_PORT; | ||
176 | } | ||
177 | |||
178 | // Get PID file location | ||
179 | const char *tmp_pid_file; | ||
180 | |||
181 | if (config_lookup_string(&cfg, NAME_PID_FILE_PATH, &tmp_pid_file) == CONFIG_FALSE) { | ||
182 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_PID_FILE_PATH); | ||
183 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_PID_FILE_PATH, DEFAULT_PID_FILE_PATH); | ||
184 | tmp_pid_file = DEFAULT_PID_FILE_PATH; | ||
185 | } | ||
186 | |||
187 | *pid_file_path = malloc(strlen(tmp_pid_file) + 1); | ||
188 | strcpy(*pid_file_path, tmp_pid_file); | ||
189 | |||
190 | // Get keys file location | ||
191 | const char *tmp_keys_file; | ||
192 | |||
193 | if (config_lookup_string(&cfg, NAME_KEYS_FILE_PATH, &tmp_keys_file) == CONFIG_FALSE) { | ||
194 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_KEYS_FILE_PATH); | ||
195 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_KEYS_FILE_PATH, DEFAULT_KEYS_FILE_PATH); | ||
196 | tmp_keys_file = DEFAULT_KEYS_FILE_PATH; | ||
197 | } | ||
198 | |||
199 | *keys_file_path = malloc(strlen(tmp_keys_file) + 1); | ||
200 | strcpy(*keys_file_path, tmp_keys_file); | ||
201 | |||
202 | // Get IPv6 option | ||
203 | if (config_lookup_bool(&cfg, NAME_ENABLE_IPV6, enable_ipv6) == CONFIG_FALSE) { | ||
204 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_IPV6); | ||
205 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_IPV6, DEFAULT_ENABLE_IPV6 ? "true" : "false"); | ||
206 | *enable_ipv6 = DEFAULT_ENABLE_IPV6; | ||
207 | } | ||
208 | |||
209 | // Get IPv4 fallback option | ||
210 | if (config_lookup_bool(&cfg, NAME_ENABLE_IPV4_FALLBACK, enable_ipv4_fallback) == CONFIG_FALSE) { | ||
211 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_IPV4_FALLBACK); | ||
212 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_IPV4_FALLBACK, | ||
213 | DEFAULT_ENABLE_IPV4_FALLBACK ? "true" : "false"); | ||
214 | *enable_ipv4_fallback = DEFAULT_ENABLE_IPV4_FALLBACK; | ||
215 | } | ||
216 | |||
217 | // Get LAN discovery option | ||
218 | if (config_lookup_bool(&cfg, NAME_ENABLE_LAN_DISCOVERY, enable_lan_discovery) == CONFIG_FALSE) { | ||
219 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_LAN_DISCOVERY); | ||
220 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_LAN_DISCOVERY, | ||
221 | DEFAULT_ENABLE_LAN_DISCOVERY ? "true" : "false"); | ||
222 | *enable_lan_discovery = DEFAULT_ENABLE_LAN_DISCOVERY; | ||
223 | } | ||
224 | |||
225 | // Get TCP relay option | ||
226 | if (config_lookup_bool(&cfg, NAME_ENABLE_TCP_RELAY, enable_tcp_relay) == CONFIG_FALSE) { | ||
227 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_TCP_RELAY); | ||
228 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_TCP_RELAY, | ||
229 | DEFAULT_ENABLE_TCP_RELAY ? "true" : "false"); | ||
230 | *enable_tcp_relay = DEFAULT_ENABLE_TCP_RELAY; | ||
231 | } | ||
232 | |||
233 | if (*enable_tcp_relay) { | ||
234 | parse_tcp_relay_ports_config(&cfg, tcp_relay_ports, tcp_relay_port_count); | ||
235 | } else { | ||
236 | *tcp_relay_port_count = 0; | ||
237 | } | ||
238 | |||
239 | // Get MOTD option | ||
240 | if (config_lookup_bool(&cfg, NAME_ENABLE_MOTD, enable_motd) == CONFIG_FALSE) { | ||
241 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_ENABLE_MOTD); | ||
242 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_ENABLE_MOTD, | ||
243 | DEFAULT_ENABLE_MOTD ? "true" : "false"); | ||
244 | *enable_motd = DEFAULT_ENABLE_MOTD; | ||
245 | } | ||
246 | |||
247 | if (*enable_motd) { | ||
248 | // Get MOTD | ||
249 | const char *tmp_motd; | ||
250 | |||
251 | if (config_lookup_string(&cfg, NAME_MOTD, &tmp_motd) == CONFIG_FALSE) { | ||
252 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in configuration file.\n", NAME_MOTD); | ||
253 | write_log(LOG_LEVEL_WARNING, "Using default '%s': %s\n", NAME_MOTD, DEFAULT_MOTD); | ||
254 | tmp_motd = DEFAULT_MOTD; | ||
255 | } | ||
256 | |||
257 | size_t tmp_motd_length = strlen(tmp_motd) + 1; | ||
258 | size_t motd_length = tmp_motd_length > MAX_MOTD_LENGTH ? MAX_MOTD_LENGTH : tmp_motd_length; | ||
259 | *motd = malloc(motd_length); | ||
260 | strncpy(*motd, tmp_motd, motd_length); | ||
261 | (*motd)[motd_length - 1] = '\0'; | ||
262 | } | ||
263 | |||
264 | config_destroy(&cfg); | ||
265 | |||
266 | write_log(LOG_LEVEL_INFO, "Successfully read:\n"); | ||
267 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_PID_FILE_PATH, *pid_file_path); | ||
268 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_KEYS_FILE_PATH, *keys_file_path); | ||
269 | write_log(LOG_LEVEL_INFO, "'%s': %d\n", NAME_PORT, *port); | ||
270 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_IPV6, *enable_ipv6 ? "true" : "false"); | ||
271 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_IPV4_FALLBACK, *enable_ipv4_fallback ? "true" : "false"); | ||
272 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_LAN_DISCOVERY, *enable_lan_discovery ? "true" : "false"); | ||
273 | |||
274 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false"); | ||
275 | |||
276 | // show info about tcp ports only if tcp relay is enabled | ||
277 | if (*enable_tcp_relay) { | ||
278 | if (*tcp_relay_port_count == 0) { | ||
279 | write_log(LOG_LEVEL_ERROR, "No TCP ports could be read.\n"); | ||
280 | } else { | ||
281 | write_log(LOG_LEVEL_INFO, "Read %d TCP ports:\n", *tcp_relay_port_count); | ||
282 | int i; | ||
283 | |||
284 | for (i = 0; i < *tcp_relay_port_count; i ++) { | ||
285 | write_log(LOG_LEVEL_INFO, "Port #%d: %u\n", i, (*tcp_relay_ports)[i]); | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | |||
290 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_MOTD, *enable_motd ? "true" : "false"); | ||
291 | |||
292 | if (*enable_motd) { | ||
293 | write_log(LOG_LEVEL_INFO, "'%s': %s\n", NAME_MOTD, *motd); | ||
294 | } | ||
295 | |||
296 | return 1; | ||
297 | } | ||
298 | |||
299 | int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6) | ||
300 | { | ||
301 | const char *NAME_BOOTSTRAP_NODES = "bootstrap_nodes"; | ||
302 | |||
303 | const char *NAME_PUBLIC_KEY = "public_key"; | ||
304 | const char *NAME_PORT = "port"; | ||
305 | const char *NAME_ADDRESS = "address"; | ||
306 | |||
307 | config_t cfg; | ||
308 | |||
309 | config_init(&cfg); | ||
310 | |||
311 | if (config_read_file(&cfg, cfg_file_path) == CONFIG_FALSE) { | ||
312 | write_log(LOG_LEVEL_ERROR, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg)); | ||
313 | config_destroy(&cfg); | ||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | config_setting_t *node_list = config_lookup(&cfg, NAME_BOOTSTRAP_NODES); | ||
318 | |||
319 | if (node_list == NULL) { | ||
320 | write_log(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n", NAME_BOOTSTRAP_NODES); | ||
321 | config_destroy(&cfg); | ||
322 | return 1; | ||
323 | } | ||
324 | |||
325 | if (config_setting_length(node_list) == 0) { | ||
326 | write_log(LOG_LEVEL_WARNING, "No bootstrap nodes found. Skipping bootstrapping.\n"); | ||
327 | config_destroy(&cfg); | ||
328 | return 1; | ||
329 | } | ||
330 | |||
331 | int bs_port; | ||
332 | const char *bs_address; | ||
333 | const char *bs_public_key; | ||
334 | |||
335 | config_setting_t *node; | ||
336 | |||
337 | int i = 0; | ||
338 | |||
339 | while (config_setting_length(node_list)) { | ||
340 | |||
341 | node = config_setting_get_elem(node_list, 0); | ||
342 | |||
343 | if (node == NULL) { | ||
344 | config_destroy(&cfg); | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | // Check that all settings are present | ||
349 | if (config_setting_lookup_string(node, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE) { | ||
350 | write_log(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_PUBLIC_KEY); | ||
351 | goto next; | ||
352 | } | ||
353 | |||
354 | if (config_setting_lookup_int(node, NAME_PORT, &bs_port) == CONFIG_FALSE) { | ||
355 | write_log(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_PORT); | ||
356 | goto next; | ||
357 | } | ||
358 | |||
359 | if (config_setting_lookup_string(node, NAME_ADDRESS, &bs_address) == CONFIG_FALSE) { | ||
360 | write_log(LOG_LEVEL_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_ADDRESS); | ||
361 | goto next; | ||
362 | } | ||
363 | |||
364 | // Process settings | ||
365 | if (strlen(bs_public_key) != crypto_box_PUBLICKEYBYTES * 2) { | ||
366 | write_log(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_PUBLIC_KEY, | ||
367 | bs_public_key); | ||
368 | goto next; | ||
369 | } | ||
370 | |||
371 | if (bs_port < MIN_ALLOWED_PORT || bs_port > MAX_ALLOWED_PORT) { | ||
372 | write_log(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %d, should be in [%d, %d]. Skipping the node.\n", i, NAME_PORT, | ||
373 | bs_port, MIN_ALLOWED_PORT, MAX_ALLOWED_PORT); | ||
374 | goto next; | ||
375 | } | ||
376 | |||
377 | uint8_t *bs_public_key_bin = hex_string_to_bin((char *)bs_public_key); | ||
378 | const int address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port), | ||
379 | bs_public_key_bin); | ||
380 | free(bs_public_key_bin); | ||
381 | |||
382 | if (!address_resolved) { | ||
383 | write_log(LOG_LEVEL_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_ADDRESS, bs_address); | ||
384 | goto next; | ||
385 | } | ||
386 | |||
387 | write_log(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key); | ||
388 | |||
389 | next: | ||
390 | // config_setting_lookup_string() allocates string inside and doesn't allow us to free it direcly | ||
391 | // though it's freed when the element is removed, so we free it right away in order to keep memory | ||
392 | // consumption minimal | ||
393 | config_setting_remove_elem(node_list, 0); | ||
394 | i++; | ||
395 | } | ||
396 | |||
397 | config_destroy(&cfg); | ||
398 | |||
399 | return 1; | ||
400 | } | ||