… | |
… | |
88 | ); |
88 | ); |
89 | } |
89 | } |
90 | |
90 | |
91 | conf_node::~conf_node () |
91 | conf_node::~conf_node () |
92 | { |
92 | { |
|
|
93 | #if 0 |
|
|
94 | // does not work, because string pointers etc. are shared |
|
|
95 | // is not called, however |
93 | if (rsa_key) |
96 | if (rsa_key) |
94 | RSA_free (rsa_key); |
97 | RSA_free (rsa_key); |
95 | |
98 | |
96 | free (nodename); |
99 | free (nodename); |
97 | free (hostname); |
100 | free (hostname); |
|
|
101 | free (if_up_data); |
98 | #if ENABLE_DNS |
102 | #if ENABLE_DNS |
99 | free (domain); |
103 | free (domain); |
100 | free (dns_hostname); |
104 | free (dns_hostname); |
|
|
105 | #endif |
101 | #endif |
106 | #endif |
102 | } |
107 | } |
103 | |
108 | |
104 | void configuration::init () |
109 | void configuration::init () |
105 | { |
110 | { |
… | |
… | |
118 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
123 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
119 | default_node.connectmode = conf_node::C_ALWAYS; |
124 | default_node.connectmode = conf_node::C_ALWAYS; |
120 | default_node.compress = true; |
125 | default_node.compress = true; |
121 | default_node.protocols = 0; |
126 | default_node.protocols = 0; |
122 | default_node.max_retry = DEFAULT_MAX_RETRY; |
127 | default_node.max_retry = DEFAULT_MAX_RETRY; |
|
|
128 | default_node.if_up_data = strdup (""); |
123 | |
129 | |
124 | #if ENABLE_DNS |
130 | #if ENABLE_DNS |
125 | default_node.dns_port = 0; // default is 0 == client |
131 | default_node.dns_port = 0; // default is 0 == client |
|
|
132 | |
126 | dns_forw_host = strdup ("127.0.0.1"); |
133 | dns_forw_host = strdup ("127.0.0.1"); |
127 | dns_forw_port = 53; |
134 | dns_forw_port = 53; |
|
|
135 | dns_timeout_factor = DEFAULT_DNS_TIMEOUT_FACTOR; |
|
|
136 | dns_send_interval = DEFAULT_DNS_SEND_INTERVAL; |
|
|
137 | dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR; |
|
|
138 | dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING; |
128 | #endif |
139 | #endif |
129 | |
140 | |
130 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
141 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
131 | } |
142 | } |
132 | |
143 | |
… | |
… | |
158 | |
169 | |
159 | cleanup (); |
170 | cleanup (); |
160 | init (); |
171 | init (); |
161 | } |
172 | } |
162 | |
173 | |
163 | #define parse_bool(target,name,trueval,falseval) \ |
174 | #define parse_bool(target,name,trueval,falseval) do { \ |
164 | if (!strcmp (val, "yes")) target = trueval; \ |
175 | if (!strcmp (val, "yes")) target = trueval; \ |
165 | else if (!strcmp (val, "no")) target = falseval; \ |
176 | else if (!strcmp (val, "no")) target = falseval; \ |
166 | else if (!strcmp (val, "true")) target = trueval; \ |
177 | else if (!strcmp (val, "true")) target = trueval; \ |
167 | else if (!strcmp (val, "false")) target = falseval; \ |
178 | else if (!strcmp (val, "false")) target = falseval; \ |
168 | else if (!strcmp (val, "on")) target = trueval; \ |
179 | else if (!strcmp (val, "on")) target = trueval; \ |
169 | else if (!strcmp (val, "off")) target = falseval; \ |
180 | else if (!strcmp (val, "off")) target = falseval; \ |
170 | else \ |
181 | else \ |
171 | slog (L_WARN, \ |
182 | slog (L_WARN, \ |
172 | _("illegal value for '%s', only 'yes|true|on' or 'no|false|off' allowed, at '%s' line %d"), \ |
183 | _("illegal value for '%s', only 'yes|true|on' or 'no|false|off' allowed, at '%s' line %d"), \ |
173 | name, var, fname, lineno); |
184 | name, var, fname, lineno); \ |
|
|
185 | } while (0) |
174 | |
186 | |
175 | void configuration::read_config (bool need_keys) |
187 | void configuration::read_config (bool need_keys) |
176 | { |
188 | { |
177 | char *fname; |
189 | char *fname; |
178 | FILE *f; |
190 | FILE *f; |
… | |
… | |
330 | { |
342 | { |
331 | #if ENABLE_DNS |
343 | #if ENABLE_DNS |
332 | dns_forw_port = atoi (val); |
344 | dns_forw_port = atoi (val); |
333 | #endif |
345 | #endif |
334 | } |
346 | } |
|
|
347 | else if (!strcmp (var, "dns-timeout-factor")) |
|
|
348 | { |
|
|
349 | #if ENABLE_DNS |
|
|
350 | dns_timeout_factor = atof (val); |
|
|
351 | #endif |
|
|
352 | } |
|
|
353 | else if (!strcmp (var, "dns-send-interval")) |
|
|
354 | { |
|
|
355 | #if ENABLE_DNS |
|
|
356 | dns_send_interval = atoi (val); |
|
|
357 | #endif |
|
|
358 | } |
|
|
359 | else if (!strcmp (var, "dns-overlap-factor")) |
|
|
360 | { |
|
|
361 | #if ENABLE_DNS |
|
|
362 | dns_overlap_factor = atof (val); |
|
|
363 | #endif |
|
|
364 | } |
|
|
365 | else if (!strcmp (var, "dns-max-outstanding")) |
|
|
366 | { |
|
|
367 | #if ENABLE_DNS |
|
|
368 | dns_max_outstanding = atoi (val); |
|
|
369 | #endif |
|
|
370 | } |
335 | else if (!strcmp (var, "http-proxy-host")) |
371 | else if (!strcmp (var, "http-proxy-host")) |
336 | { |
372 | { |
337 | #if ENABLE_HTTP_PROXY |
373 | #if ENABLE_HTTP_PROXY |
338 | free (proxy_host), proxy_host = strdup (val); |
374 | free (proxy_host), proxy_host = strdup (val); |
339 | #endif |
375 | #endif |
… | |
… | |
376 | { |
412 | { |
377 | #if ENABLE_DNS |
413 | #if ENABLE_DNS |
378 | free (node->domain), node->domain = strdup (val); |
414 | free (node->domain), node->domain = strdup (val); |
379 | #endif |
415 | #endif |
380 | } |
416 | } |
|
|
417 | else if (!strcmp (var, "if-up-data")) |
|
|
418 | free (node->if_up_data), node->if_up_data = strdup (val); |
381 | else if (!strcmp (var, "router-priority")) |
419 | else if (!strcmp (var, "router-priority")) |
382 | node->routerprio = atoi (val); |
420 | node->routerprio = atoi (val); |
383 | else if (!strcmp (var, "max-retry")) |
421 | else if (!strcmp (var, "max-retry")) |
384 | node->max_retry = atoi (val); |
422 | node->max_retry = atoi (val); |
385 | else if (!strcmp (var, "connect")) |
423 | else if (!strcmp (var, "connect")) |