ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/conf.C
(Generate patch)

Comparing gvpe/src/conf.C (file contents):
Revision 1.34 by pcg, Thu Mar 17 23:59:37 2005 UTC vs.
Revision 1.39 by pcg, Sat Mar 26 03:16:24 2005 UTC

37#include <openssl/pem.h> 37#include <openssl/pem.h>
38#include <openssl/rsa.h> 38#include <openssl/rsa.h>
39#include <openssl/rand.h> 39#include <openssl/rand.h>
40#include <openssl/bn.h> 40#include <openssl/bn.h>
41 41
42#include "gettext.h"
43
44#include "conf.h" 42#include "conf.h"
45#include "slog.h" 43#include "slog.h"
46#include "util.h" 44#include "util.h"
47 45
48char *confbase; 46char *confbase;
90 ); 88 );
91} 89}
92 90
93conf_node::~conf_node () 91conf_node::~conf_node ()
94{ 92{
93#if 0
94 // does not work, because string pointers etc. are shared
95 // is not called, however
95 if (rsa_key) 96 if (rsa_key)
96 RSA_free (rsa_key); 97 RSA_free (rsa_key);
97 98
98 free (nodename); 99 free (nodename);
99 free (hostname); 100 free (hostname);
101 free (if_up_data);
100#if ENABLE_DNS 102#if ENABLE_DNS
101 free (domain); 103 free (domain);
102 free (dns_hostname); 104 free (dns_hostname);
105#endif
103#endif 106#endif
104} 107}
105 108
106void configuration::init () 109void configuration::init ()
107{ 110{
120 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm 123 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
121 default_node.connectmode = conf_node::C_ALWAYS; 124 default_node.connectmode = conf_node::C_ALWAYS;
122 default_node.compress = true; 125 default_node.compress = true;
123 default_node.protocols = 0; 126 default_node.protocols = 0;
124 default_node.max_retry = DEFAULT_MAX_RETRY; 127 default_node.max_retry = DEFAULT_MAX_RETRY;
128 default_node.if_up_data = strdup ("");
125 129
126#if ENABLE_DNS 130#if ENABLE_DNS
127 default_node.dns_port = 0; // default is 0 == client 131 default_node.dns_port = 0; // default is 0 == client
132
128 dns_forw_host = strdup ("127.0.0.1"); 133 dns_forw_host = strdup ("127.0.0.1");
129 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;
130#endif 139#endif
131 140
132 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); 141 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
133} 142}
134 143
160 169
161 cleanup (); 170 cleanup ();
162 init (); 171 init ();
163} 172}
164 173
165#define parse_bool(target,name,trueval,falseval) \ 174#define parse_bool(target,name,trueval,falseval) do { \
166 if (!strcmp (val, "yes")) target = trueval; \ 175 if (!strcmp (val, "yes")) target = trueval; \
167 else if (!strcmp (val, "no")) target = falseval; \ 176 else if (!strcmp (val, "no")) target = falseval; \
168 else if (!strcmp (val, "true")) target = trueval; \ 177 else if (!strcmp (val, "true")) target = trueval; \
169 else if (!strcmp (val, "false")) target = falseval; \ 178 else if (!strcmp (val, "false")) target = falseval; \
170 else if (!strcmp (val, "on")) target = trueval; \ 179 else if (!strcmp (val, "on")) target = trueval; \
171 else if (!strcmp (val, "off")) target = falseval; \ 180 else if (!strcmp (val, "off")) target = falseval; \
172 else \ 181 else \
173 slog (L_WARN, \ 182 slog (L_WARN, \
174 _("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"), \
175 name, var, fname, lineno); 184 name, var, fname, lineno); \
185} while (0)
176 186
177void configuration::read_config (bool need_keys) 187void configuration::read_config (bool need_keys)
178{ 188{
179 char *fname; 189 char *fname;
180 FILE *f; 190 FILE *f;
219 val = strtok (NULL, "\t\n\r ="); 229 val = strtok (NULL, "\t\n\r =");
220 230
221 if (!val || val[0] == '#') 231 if (!val || val[0] == '#')
222 { 232 {
223 slog (L_WARN, 233 slog (L_WARN,
224 _("no value for variable `%s', at '%s' line %d"), 234 _("no value for variable `%s', at '%s' line %d, skipping."),
225 var, fname, lineno); 235 var, fname, lineno);
226 break; 236 continue;
227 } 237 }
228 238
229 if (!strcmp (var, "on")) 239 if (!strcmp (var, "on"))
230 { 240 {
231 if (!::thisnode 241 if (!::thisnode
303 thisnode = node; 313 thisnode = node;
304 } 314 }
305 else if (!strcmp (var, "private-key")) 315 else if (!strcmp (var, "private-key"))
306 free (prikeyfile), prikeyfile = strdup (val); 316 free (prikeyfile), prikeyfile = strdup (val);
307 else if (!strcmp (var, "ifpersist")) 317 else if (!strcmp (var, "ifpersist"))
308 {
309 parse_bool (ifpersist, "ifpersist", true, false); 318 parse_bool (ifpersist, "ifpersist", true, false);
310 }
311 else if (!strcmp (var, "ifname")) 319 else if (!strcmp (var, "ifname"))
312 free (ifname), ifname = strdup (val); 320 free (ifname), ifname = strdup (val);
313 else if (!strcmp (var, "rekey")) 321 else if (!strcmp (var, "rekey"))
314 rekey = atoi (val); 322 rekey = atoi (val);
315 else if (!strcmp (var, "keepalive")) 323 else if (!strcmp (var, "keepalive"))
334 { 342 {
335#if ENABLE_DNS 343#if ENABLE_DNS
336 dns_forw_port = atoi (val); 344 dns_forw_port = atoi (val);
337#endif 345#endif
338 } 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 }
339 else if (!strcmp (var, "http-proxy-host")) 371 else if (!strcmp (var, "http-proxy-host"))
340 { 372 {
341#if ENABLE_HTTP_PROXY 373#if ENABLE_HTTP_PROXY
342 free (proxy_host), proxy_host = strdup (val); 374 free (proxy_host), proxy_host = strdup (val);
343#endif 375#endif
380 { 412 {
381#if ENABLE_DNS 413#if ENABLE_DNS
382 free (node->domain), node->domain = strdup (val); 414 free (node->domain), node->domain = strdup (val);
383#endif 415#endif
384 } 416 }
417 else if (!strcmp (var, "if-up-data"))
418 free (node->if_up_data), node->if_up_data = strdup (val);
385 else if (!strcmp (var, "router-priority")) 419 else if (!strcmp (var, "router-priority"))
386 node->routerprio = atoi (val); 420 node->routerprio = atoi (val);
387 else if (!strcmp (var, "max-retry")) 421 else if (!strcmp (var, "max-retry"))
388 node->max_retry = atoi (val); 422 node->max_retry = atoi (val);
389 else if (!strcmp (var, "connect")) 423 else if (!strcmp (var, "connect"))
396 node->connectmode = conf_node::C_ALWAYS; 430 node->connectmode = conf_node::C_ALWAYS;
397 else if (!strcmp (val, "disabled")) 431 else if (!strcmp (val, "disabled"))
398 node->connectmode = conf_node::C_DISABLED; 432 node->connectmode = conf_node::C_DISABLED;
399 else 433 else
400 slog (L_WARN, 434 slog (L_WARN,
401 _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), 435 _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d, ignoring."),
402 var, fname, lineno); 436 var, fname, lineno);
403 } 437 }
404 else if (!strcmp (var, "inherit-tos")) 438 else if (!strcmp (var, "inherit-tos"))
405 {
406 parse_bool (node->inherit_tos, "inherit-tos", true, false); 439 parse_bool (node->inherit_tos, "inherit-tos", true, false);
407 }
408 else if (!strcmp (var, "compress")) 440 else if (!strcmp (var, "compress"))
409 {
410 parse_bool (node->compress, "compress", true, false); 441 parse_bool (node->compress, "compress", true, false);
411 }
412 // all these bool options really really cost a lot of executable size! 442 // all these bool options really really cost a lot of executable size!
413 else if (!strcmp (var, "enable-tcp")) 443 else if (!strcmp (var, "enable-tcp"))
414 { 444 {
415#if ENABLE_TCP 445#if ENABLE_TCP
416 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; 446 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v;
438 } 468 }
439 469
440 // unknown or misplaced 470 // unknown or misplaced
441 else 471 else
442 slog (L_WARN, 472 slog (L_WARN,
443 _("unknown or misplaced variable `%s', at '%s' line %d"), 473 _("unknown or misplaced variable `%s', at '%s' line %d, skipping."),
444 var, fname, lineno); 474 var, fname, lineno);
445 } 475 }
446 476
447 fclose (f); 477 fclose (f);
448 } 478 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines