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.25 by pcg, Mon May 10 20:13:09 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 asprintf (&confbase, "%s/vpe", CONFDIR);
103
104 memset (this, 0, sizeof (*this)); 106 memset (this, 0, sizeof (*this));
105 107
106 mtu = DEFAULT_MTU; 108 mtu = DEFAULT_MTU;
107 rekey = DEFAULT_REKEY; 109 rekey = DEFAULT_REKEY;
108 keepalive = DEFAULT_KEEPALIVE; 110 keepalive = DEFAULT_KEEPALIVE;
114 116
115 default_node.udp_port = DEFAULT_UDPPORT; 117 default_node.udp_port = DEFAULT_UDPPORT;
116 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm 118 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
117 default_node.connectmode = conf_node::C_ALWAYS; 119 default_node.connectmode = conf_node::C_ALWAYS;
118 default_node.compress = true; 120 default_node.compress = true;
119 default_node.protocols = PROT_UDPv4; 121 default_node.protocols = 0;
122 default_node.max_retry = DEFAULT_MAX_RETRY;
120 123
124#if ENABLE_DNS
125 default_node.dns_port = 53;
126 dns_forw_port = 53;
127#endif
128
121 conf.pidfilename = strdup (LOCALSTATEDIR "/run/vped.pid"); 129 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
122} 130}
123 131
124void configuration::cleanup() 132void configuration::cleanup()
125{ 133{
126 if (rsa_key) 134 if (rsa_key)
127 RSA_free (rsa_key); 135 RSA_free (rsa_key);
128 136
129 rsa_key = 0; 137 rsa_key = 0;
130 138
131 free (pidfilename); pidfilename = 0; 139 free (pidfilename); pidfilename = 0;
132 free (ifname); ifname = 0; 140 free (ifname); ifname = 0;
133#if ENABLE_HTTP_PROXY 141#if ENABLE_HTTP_PROXY
134 free (proxy_host); proxy_host = 0; 142 free (proxy_host); proxy_host = 0;
135 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;
136#endif 147#endif
137} 148}
138 149
139void 150void
140configuration::clear_config () 151configuration::clear_config ()
165 char *fname; 176 char *fname;
166 FILE *f; 177 FILE *f;
167 178
168 clear_config (); 179 clear_config ();
169 180
170 asprintf (&fname, "%s/vped.conf", confbase); 181 asprintf (&fname, "%s/gvpe.conf", confbase);
171 f = fopen (fname, "r"); 182 f = fopen (fname, "r");
172 183
173 if (f) 184 if (f)
174 { 185 {
175 char line[16384]; 186 char line[16384];
308 free (script_node_up), script_node_up = strdup (val); 319 free (script_node_up), script_node_up = strdup (val);
309 else if (!strcmp (var, "node-down")) 320 else if (!strcmp (var, "node-down"))
310 free (script_node_down), script_node_down = strdup (val); 321 free (script_node_down), script_node_down = strdup (val);
311 else if (!strcmp (var, "pid-file")) 322 else if (!strcmp (var, "pid-file"))
312 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
313 else if (!strcmp (var, "http-proxy-host")) 330 else if (!strcmp (var, "http-proxy-host"))
314 { 331 {
315#if ENABLE_HTTP_PROXY 332#if ENABLE_HTTP_PROXY
316 free (proxy_host), proxy_host = strdup (val); 333 free (proxy_host), proxy_host = strdup (val);
317#endif 334#endif
336 /* node-specific, defaultable */ 353 /* node-specific, defaultable */
337 else if (!strcmp (var, "udp-port")) 354 else if (!strcmp (var, "udp-port"))
338 node->udp_port = atoi (val); 355 node->udp_port = atoi (val);
339 else if (!strcmp (var, "tcp-port")) 356 else if (!strcmp (var, "tcp-port"))
340 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);
341 else if (!strcmp (var, "dns-port")) 361 else if (!strcmp (var, "dns-port"))
342 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 }
343 else if (!strcmp (var, "router-priority")) 370 else if (!strcmp (var, "router-priority"))
344 node->routerprio = atoi (val); 371 node->routerprio = atoi (val);
372 else if (!strcmp (var, "max-retry"))
373 node->max_retry = atoi (val);
345 else if (!strcmp (var, "connect")) 374 else if (!strcmp (var, "connect"))
346 { 375 {
347 if (!strcmp (val, "ondemand")) 376 if (!strcmp (val, "ondemand"))
348 node->connectmode = conf_node::C_ONDEMAND; 377 node->connectmode = conf_node::C_ONDEMAND;
349 else if (!strcmp (val, "never")) 378 else if (!strcmp (val, "never"))
352 node->connectmode = conf_node::C_ALWAYS; 381 node->connectmode = conf_node::C_ALWAYS;
353 else if (!strcmp (val, "disabled")) 382 else if (!strcmp (val, "disabled"))
354 node->connectmode = conf_node::C_DISABLED; 383 node->connectmode = conf_node::C_DISABLED;
355 else 384 else
356 slog (L_WARN, 385 slog (L_WARN,
357 _("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"),
358 var, fname, lineno); 387 var, fname, lineno);
359 } 388 }
360 else if (!strcmp (var, "inherit-tos")) 389 else if (!strcmp (var, "inherit-tos"))
361 { 390 {
362 parse_bool (node->inherit_tos, "inherit-tos", true, false); 391 parse_bool (node->inherit_tos, "inherit-tos", true, false);
363 } 392 }
387 else if (!strcmp (var, "enable-udp")) 416 else if (!strcmp (var, "enable-udp"))
388 { 417 {
389 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;
390 } 419 }
391 else if (!strcmp (var, "enable-rawip")) 420 else if (!strcmp (var, "enable-rawip"))
392 {; 421 {
393 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;
394 } 423 }
395 424
396 // unknown or misplaced 425 // unknown or misplaced
397 else 426 else
487 printf ("\n"); 516 printf ("\n");
488} 517}
489 518
490configuration::configuration () 519configuration::configuration ()
491{ 520{
521 asprintf (&confbase, "%s/gvpe", CONFDIR);
522
492 init (); 523 init ();
493} 524}
494 525
495configuration::~configuration () 526configuration::~configuration ()
496{ 527{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines