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.35 by pcg, Fri Mar 18 01:53:05 2005 UTC vs.
Revision 1.39 by pcg, Sat Mar 26 03:16:24 2005 UTC

88 ); 88 );
89} 89}
90 90
91conf_node::~conf_node () 91conf_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
104void configuration::init () 109void 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
175void configuration::read_config (bool need_keys) 187void configuration::read_config (bool need_keys)
176{ 188{
177 char *fname; 189 char *fname;
178 FILE *f; 190 FILE *f;
217 val = strtok (NULL, "\t\n\r ="); 229 val = strtok (NULL, "\t\n\r =");
218 230
219 if (!val || val[0] == '#') 231 if (!val || val[0] == '#')
220 { 232 {
221 slog (L_WARN, 233 slog (L_WARN,
222 _("no value for variable `%s', at '%s' line %d"), 234 _("no value for variable `%s', at '%s' line %d, skipping."),
223 var, fname, lineno); 235 var, fname, lineno);
224 break; 236 continue;
225 } 237 }
226 238
227 if (!strcmp (var, "on")) 239 if (!strcmp (var, "on"))
228 { 240 {
229 if (!::thisnode 241 if (!::thisnode
301 thisnode = node; 313 thisnode = node;
302 } 314 }
303 else if (!strcmp (var, "private-key")) 315 else if (!strcmp (var, "private-key"))
304 free (prikeyfile), prikeyfile = strdup (val); 316 free (prikeyfile), prikeyfile = strdup (val);
305 else if (!strcmp (var, "ifpersist")) 317 else if (!strcmp (var, "ifpersist"))
306 {
307 parse_bool (ifpersist, "ifpersist", true, false); 318 parse_bool (ifpersist, "ifpersist", true, false);
308 }
309 else if (!strcmp (var, "ifname")) 319 else if (!strcmp (var, "ifname"))
310 free (ifname), ifname = strdup (val); 320 free (ifname), ifname = strdup (val);
311 else if (!strcmp (var, "rekey")) 321 else if (!strcmp (var, "rekey"))
312 rekey = atoi (val); 322 rekey = atoi (val);
313 else if (!strcmp (var, "keepalive")) 323 else if (!strcmp (var, "keepalive"))
332 { 342 {
333#if ENABLE_DNS 343#if ENABLE_DNS
334 dns_forw_port = atoi (val); 344 dns_forw_port = atoi (val);
335#endif 345#endif
336 } 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 }
337 else if (!strcmp (var, "http-proxy-host")) 371 else if (!strcmp (var, "http-proxy-host"))
338 { 372 {
339#if ENABLE_HTTP_PROXY 373#if ENABLE_HTTP_PROXY
340 free (proxy_host), proxy_host = strdup (val); 374 free (proxy_host), proxy_host = strdup (val);
341#endif 375#endif
378 { 412 {
379#if ENABLE_DNS 413#if ENABLE_DNS
380 free (node->domain), node->domain = strdup (val); 414 free (node->domain), node->domain = strdup (val);
381#endif 415#endif
382 } 416 }
417 else if (!strcmp (var, "if-up-data"))
418 free (node->if_up_data), node->if_up_data = strdup (val);
383 else if (!strcmp (var, "router-priority")) 419 else if (!strcmp (var, "router-priority"))
384 node->routerprio = atoi (val); 420 node->routerprio = atoi (val);
385 else if (!strcmp (var, "max-retry")) 421 else if (!strcmp (var, "max-retry"))
386 node->max_retry = atoi (val); 422 node->max_retry = atoi (val);
387 else if (!strcmp (var, "connect")) 423 else if (!strcmp (var, "connect"))
394 node->connectmode = conf_node::C_ALWAYS; 430 node->connectmode = conf_node::C_ALWAYS;
395 else if (!strcmp (val, "disabled")) 431 else if (!strcmp (val, "disabled"))
396 node->connectmode = conf_node::C_DISABLED; 432 node->connectmode = conf_node::C_DISABLED;
397 else 433 else
398 slog (L_WARN, 434 slog (L_WARN,
399 _("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."),
400 var, fname, lineno); 436 var, fname, lineno);
401 } 437 }
402 else if (!strcmp (var, "inherit-tos")) 438 else if (!strcmp (var, "inherit-tos"))
403 {
404 parse_bool (node->inherit_tos, "inherit-tos", true, false); 439 parse_bool (node->inherit_tos, "inherit-tos", true, false);
405 }
406 else if (!strcmp (var, "compress")) 440 else if (!strcmp (var, "compress"))
407 {
408 parse_bool (node->compress, "compress", true, false); 441 parse_bool (node->compress, "compress", true, false);
409 }
410 // 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!
411 else if (!strcmp (var, "enable-tcp")) 443 else if (!strcmp (var, "enable-tcp"))
412 { 444 {
413#if ENABLE_TCP 445#if ENABLE_TCP
414 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;
436 } 468 }
437 469
438 // unknown or misplaced 470 // unknown or misplaced
439 else 471 else
440 slog (L_WARN, 472 slog (L_WARN,
441 _("unknown or misplaced variable `%s', at '%s' line %d"), 473 _("unknown or misplaced variable `%s', at '%s' line %d, skipping."),
442 var, fname, lineno); 474 var, fname, lineno);
443 } 475 }
444 476
445 fclose (f); 477 fclose (f);
446 } 478 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines