1 | /* |
1 | /* |
2 | conf.c -- configuration code |
2 | conf.c -- configuration code |
3 | Copyright (C) 2003-2004 Marc Lehmann <pcg@goof.com> |
3 | Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de> |
4 | |
4 | |
|
|
5 | This file is part of GVPE. |
|
|
6 | |
5 | This program is free software; you can redistribute it and/or modify |
7 | GVPE is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
8 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
9 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
10 | (at your option) any later version. |
9 | |
11 | |
10 | This program is distributed in the hope that it will be useful, |
12 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
14 | |
16 | |
15 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software |
18 | along with gvpe; if not, write to the Free Software |
17 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ |
20 | */ |
19 | |
21 | |
20 | #include "config.h" |
22 | #include "config.h" |
21 | |
23 | |
… | |
… | |
93 | if (rsa_key) |
95 | if (rsa_key) |
94 | RSA_free (rsa_key); |
96 | RSA_free (rsa_key); |
95 | |
97 | |
96 | free (nodename); |
98 | free (nodename); |
97 | free (hostname); |
99 | free (hostname); |
|
|
100 | #if ENABLE_DNS |
98 | free (domain); |
101 | free (domain); |
|
|
102 | free (dns_hostname); |
|
|
103 | #endif |
99 | } |
104 | } |
100 | |
105 | |
101 | void configuration::init () |
106 | void configuration::init () |
102 | { |
107 | { |
103 | memset (this, 0, sizeof (*this)); |
108 | memset (this, 0, sizeof (*this)); |
… | |
… | |
113 | |
118 | |
114 | default_node.udp_port = DEFAULT_UDPPORT; |
119 | default_node.udp_port = DEFAULT_UDPPORT; |
115 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
120 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
116 | default_node.connectmode = conf_node::C_ALWAYS; |
121 | default_node.connectmode = conf_node::C_ALWAYS; |
117 | default_node.compress = true; |
122 | default_node.compress = true; |
118 | default_node.protocols = PROT_UDPv4; |
123 | default_node.protocols = 0; |
119 | default_node.max_retry = DEFAULT_MAX_RETRY; |
124 | default_node.max_retry = DEFAULT_MAX_RETRY; |
|
|
125 | |
|
|
126 | #if ENABLE_DNS |
|
|
127 | default_node.dns_port = 0; // default is 0 == client |
|
|
128 | dns_forw_port = 53; |
|
|
129 | #endif |
120 | |
130 | |
121 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
131 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
122 | } |
132 | } |
123 | |
133 | |
124 | void configuration::cleanup() |
134 | void configuration::cleanup() |
… | |
… | |
311 | free (script_node_up), script_node_up = strdup (val); |
321 | free (script_node_up), script_node_up = strdup (val); |
312 | else if (!strcmp (var, "node-down")) |
322 | else if (!strcmp (var, "node-down")) |
313 | free (script_node_down), script_node_down = strdup (val); |
323 | free (script_node_down), script_node_down = strdup (val); |
314 | else if (!strcmp (var, "pid-file")) |
324 | else if (!strcmp (var, "pid-file")) |
315 | free (pidfilename), pidfilename = strdup (val); |
325 | free (pidfilename), pidfilename = strdup (val); |
|
|
326 | #if ENABLE_DNS |
316 | else if (!strcmp (var, "dns-forwarder-host")) |
327 | else if (!strcmp (var, "dns-forw-host")) |
317 | { |
|
|
318 | #if ENABLE_DNS |
|
|
319 | free (dns_forw_host), dns_forw_host = strdup (val); |
328 | free (dns_forw_host), dns_forw_host = strdup (val); |
320 | #endif |
|
|
321 | } |
|
|
322 | else if (!strcmp (var, "dns-forwarder-port")) |
329 | else if (!strcmp (var, "dns-forw-port")) |
323 | { |
|
|
324 | #if ENABLE_DNS |
|
|
325 | dns_forw_port = atoi (val); |
330 | dns_forw_port = atoi (val); |
326 | #endif |
331 | #endif |
327 | } |
|
|
328 | else if (!strcmp (var, "http-proxy-host")) |
332 | else if (!strcmp (var, "http-proxy-host")) |
329 | { |
333 | { |
330 | #if ENABLE_HTTP_PROXY |
334 | #if ENABLE_HTTP_PROXY |
331 | free (proxy_host), proxy_host = strdup (val); |
335 | free (proxy_host), proxy_host = strdup (val); |
332 | #endif |
336 | #endif |
… | |
… | |
351 | /* node-specific, defaultable */ |
355 | /* node-specific, defaultable */ |
352 | else if (!strcmp (var, "udp-port")) |
356 | else if (!strcmp (var, "udp-port")) |
353 | node->udp_port = atoi (val); |
357 | node->udp_port = atoi (val); |
354 | else if (!strcmp (var, "tcp-port")) |
358 | else if (!strcmp (var, "tcp-port")) |
355 | node->tcp_port = atoi (val); |
359 | node->tcp_port = atoi (val); |
|
|
360 | #if ENABLE_DNS |
|
|
361 | else if (!strcmp (var, "dns-hostname")) |
|
|
362 | free (node->dns_hostname), node->dns_hostname = strdup (val); |
356 | else if (!strcmp (var, "dns-port")) |
363 | else if (!strcmp (var, "dns-port")) |
357 | { |
|
|
358 | #if ENABLE_DNS |
|
|
359 | node->dns_port = atoi (val); |
364 | node->dns_port = atoi (val); |
360 | #endif |
365 | #endif |
361 | } |
|
|
362 | else if (!strcmp (var, "dns-domain")) |
366 | else if (!strcmp (var, "dns-domain")) |
363 | { |
367 | { |
364 | #if ENABLE_DNS |
368 | #if ENABLE_DNS |
365 | free (node->domain), node->domain = strdup (val); |
369 | free (node->domain), node->domain = strdup (val); |
366 | #endif |
370 | #endif |