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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines