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.24 by pcg, Fri Apr 2 14:42:45 2004 UTC vs.
Revision 1.29 by pcg, Tue Mar 1 06:27:20 2005 UTC

93 if (rsa_key) 93 if (rsa_key)
94 RSA_free (rsa_key); 94 RSA_free (rsa_key);
95 95
96 free (nodename); 96 free (nodename);
97 free (hostname); 97 free (hostname);
98 free (domain);
98} 99}
99 100
100void configuration::init () 101void configuration::init ()
101{ 102{
102 memset (this, 0, sizeof (*this)); 103 memset (this, 0, sizeof (*this));
112 113
113 default_node.udp_port = DEFAULT_UDPPORT; 114 default_node.udp_port = DEFAULT_UDPPORT;
114 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm 115 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
115 default_node.connectmode = conf_node::C_ALWAYS; 116 default_node.connectmode = conf_node::C_ALWAYS;
116 default_node.compress = true; 117 default_node.compress = true;
117 default_node.protocols = PROT_UDPv4; 118 default_node.protocols = 0;
119 default_node.max_retry = DEFAULT_MAX_RETRY;
120
121 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
118} 122}
119 123
120void configuration::cleanup() 124void configuration::cleanup()
121{ 125{
122 if (rsa_key) 126 if (rsa_key)
123 RSA_free (rsa_key); 127 RSA_free (rsa_key);
124 128
125 rsa_key = 0; 129 rsa_key = 0;
126 130
127 free (pidfilename); pidfilename = 0; 131 free (pidfilename); pidfilename = 0;
128 free (ifname); ifname = 0; 132 free (ifname); ifname = 0;
129#if ENABLE_HTTP_PROXY 133#if ENABLE_HTTP_PROXY
130 free (proxy_host); proxy_host = 0; 134 free (proxy_host); proxy_host = 0;
131 free (proxy_auth); proxy_auth = 0; 135 free (proxy_auth); proxy_auth = 0;
136#endif
137#if ENABLE_DNS
138 free (dns_forw_host); dns_forw_host = 0;
132#endif 139#endif
133} 140}
134 141
135void 142void
136configuration::clear_config () 143configuration::clear_config ()
161 char *fname; 168 char *fname;
162 FILE *f; 169 FILE *f;
163 170
164 clear_config (); 171 clear_config ();
165 172
166 asprintf (&fname, "%s/vped.conf", confbase); 173 asprintf (&fname, "%s/gvpe.conf", confbase);
167 f = fopen (fname, "r"); 174 f = fopen (fname, "r");
168 175
169 if (f) 176 if (f)
170 { 177 {
171 char line[16384]; 178 char line[16384];
304 free (script_node_up), script_node_up = strdup (val); 311 free (script_node_up), script_node_up = strdup (val);
305 else if (!strcmp (var, "node-down")) 312 else if (!strcmp (var, "node-down"))
306 free (script_node_down), script_node_down = strdup (val); 313 free (script_node_down), script_node_down = strdup (val);
307 else if (!strcmp (var, "pid-file")) 314 else if (!strcmp (var, "pid-file"))
308 free (pidfilename), pidfilename = strdup (val); 315 free (pidfilename), pidfilename = strdup (val);
316 else if (!strcmp (var, "dns-forw-host"))
317 {
318#if ENABLE_DNS
319 free (dns_forw_host), dns_forw_host = strdup (val);
320#endif
321 }
322 else if (!strcmp (var, "dns-forw-port"))
323 {
324#if ENABLE_DNS
325 dns_forw_port = atoi (val);
326#endif
327 }
309 else if (!strcmp (var, "http-proxy-host")) 328 else if (!strcmp (var, "http-proxy-host"))
310 { 329 {
311#if ENABLE_HTTP_PROXY 330#if ENABLE_HTTP_PROXY
312 free (proxy_host), proxy_host = strdup (val); 331 free (proxy_host), proxy_host = strdup (val);
313#endif 332#endif
333 else if (!strcmp (var, "udp-port")) 352 else if (!strcmp (var, "udp-port"))
334 node->udp_port = atoi (val); 353 node->udp_port = atoi (val);
335 else if (!strcmp (var, "tcp-port")) 354 else if (!strcmp (var, "tcp-port"))
336 node->tcp_port = atoi (val); 355 node->tcp_port = atoi (val);
337 else if (!strcmp (var, "dns-port")) 356 else if (!strcmp (var, "dns-port"))
357 {
358#if ENABLE_DNS
338 node->dns_port = atoi (val); 359 node->dns_port = atoi (val);
360#endif
361 }
362 else if (!strcmp (var, "dns-domain"))
363 {
364#if ENABLE_DNS
365 free (node->domain), node->domain = strdup (val);
366#endif
367 }
339 else if (!strcmp (var, "router-priority")) 368 else if (!strcmp (var, "router-priority"))
340 node->routerprio = atoi (val); 369 node->routerprio = atoi (val);
370 else if (!strcmp (var, "max-retry"))
371 node->max_retry = atoi (val);
341 else if (!strcmp (var, "connect")) 372 else if (!strcmp (var, "connect"))
342 { 373 {
343 if (!strcmp (val, "ondemand")) 374 if (!strcmp (val, "ondemand"))
344 node->connectmode = conf_node::C_ONDEMAND; 375 node->connectmode = conf_node::C_ONDEMAND;
345 else if (!strcmp (val, "never")) 376 else if (!strcmp (val, "never"))
348 node->connectmode = conf_node::C_ALWAYS; 379 node->connectmode = conf_node::C_ALWAYS;
349 else if (!strcmp (val, "disabled")) 380 else if (!strcmp (val, "disabled"))
350 node->connectmode = conf_node::C_DISABLED; 381 node->connectmode = conf_node::C_DISABLED;
351 else 382 else
352 slog (L_WARN, 383 slog (L_WARN,
353 _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), 384 _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"),
354 var, fname, lineno); 385 var, fname, lineno);
355 } 386 }
356 else if (!strcmp (var, "inherit-tos")) 387 else if (!strcmp (var, "inherit-tos"))
357 { 388 {
358 parse_bool (node->inherit_tos, "inherit-tos", true, false); 389 parse_bool (node->inherit_tos, "inherit-tos", true, false);
359 } 390 }
383 else if (!strcmp (var, "enable-udp")) 414 else if (!strcmp (var, "enable-udp"))
384 { 415 {
385 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 416 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
386 } 417 }
387 else if (!strcmp (var, "enable-rawip")) 418 else if (!strcmp (var, "enable-rawip"))
388 {; 419 {
389 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; 420 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v;
390 } 421 }
391 422
392 // unknown or misplaced 423 // unknown or misplaced
393 else 424 else
483 printf ("\n"); 514 printf ("\n");
484} 515}
485 516
486configuration::configuration () 517configuration::configuration ()
487{ 518{
519 asprintf (&confbase, "%s/gvpe", CONFDIR);
520
488 init (); 521 init ();
489} 522}
490 523
491configuration::~configuration () 524configuration::~configuration ()
492{ 525{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines