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.10 by pcg, Wed Apr 2 21:02:25 2003 UTC vs.
Revision 1.12 by pcg, Mon Apr 7 01:12:56 2003 UTC

69 if (protocol & PROT_TCPv4) return "tcp"; 69 if (protocol & PROT_TCPv4) return "tcp";
70 70
71 return "<unknown>"; 71 return "<unknown>";
72} 72}
73 73
74configuration::configuration () 74void
75conf_node::print ()
75{ 76{
76 init (); 77 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n",
78 id,
79 id >> 8, id & 0xff,
80 compress ? 'Y' : 'N',
81 connectmode == C_ONDEMAND ? "ondemand" :
82 connectmode == C_NEVER ? "never" :
83 connectmode == C_ALWAYS ? "always" : "",
84 nodename,
85 hostname ? hostname : "",
86 hostname ? ":" : "",
87 hostname ? udp_port : 0
88 );
77} 89}
78 90
79configuration::~configuration () 91conf_node::~conf_node ()
80{ 92{
81 cleanup (); 93 if (rsa_key)
94 RSA_free (rsa_key);
95
96 free (nodename);
97 free (hostname);
82} 98}
83 99
84void configuration::init () 100void configuration::init ()
85{ 101{
86 memset (this, 0, sizeof (*this)); 102 memset (this, 0, sizeof (*this));
100void configuration::cleanup() 116void configuration::cleanup()
101{ 117{
102 if (rsa_key) 118 if (rsa_key)
103 RSA_free (rsa_key); 119 RSA_free (rsa_key);
104 120
105 free (ifname);
106
107 rsa_key = 0; 121 rsa_key = 0;
108 ifname = 0; 122
123 free (ifname); ifname = 0;
124#if ENABLE_HTTP_PROXY
125 free (proxy_host); proxy_host = 0;
126 free (proxy_auth); proxy_auth = 0;
127#endif
109} 128}
110 129
111void 130void
112configuration::clear_config () 131configuration::clear_config ()
113{ 132{
272 script_if_up = strdup (val); 291 script_if_up = strdup (val);
273 else if (!strcmp (var, "node-up")) 292 else if (!strcmp (var, "node-up"))
274 script_node_up = strdup (val); 293 script_node_up = strdup (val);
275 else if (!strcmp (var, "node-down")) 294 else if (!strcmp (var, "node-down"))
276 script_node_down = strdup (val); 295 script_node_down = strdup (val);
296#if ENABLE_HTTP_PROXY
297 else if (!strcmp (var, "http-proxy-host"))
298 proxy_host = strdup (val);
299 else if (!strcmp (var, "http-proxy-port"))
300 proxy_port = atoi (val);
301 else if (!strcmp (var, "http-proxy-auth"))
302 proxy_auth = (char *)base64_encode ((const u8 *)val, strlen (val));
303#endif
277 304
278 /* node-specific, non-defaultable */ 305 /* node-specific, non-defaultable */
279 else if (node != &default_node && !strcmp (var, "hostname")) 306 else if (node != &default_node && !strcmp (var, "hostname"))
280 { 307 {
281 free (node->hostname); 308 free (node->hostname);
313 parse_bool (node->compress, "compress", true, false); 340 parse_bool (node->compress, "compress", true, false);
314 } 341 }
315 // all these bool options really really cost a lot of executable size! 342 // all these bool options really really cost a lot of executable size!
316 else if (!strcmp (var, "enable-tcp")) 343 else if (!strcmp (var, "enable-tcp"))
317 { 344 {
345#if ENABLE_TCP
318 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; 346 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v;
347#endif
319 } 348 }
320 else if (!strcmp (var, "enable-udp")) 349 else if (!strcmp (var, "enable-udp"))
321 { 350 {
322 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 351 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
323 } 352 }
326 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; 355 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v;
327 } 356 }
328 357
329 // unknown or misplaced 358 // unknown or misplaced
330 else 359 else
331 {
332 slog (L_WARN, 360 slog (L_WARN,
333 _("unknown or misplaced variable `%s', at '%s' line %d"), 361 _("unknown or misplaced variable `%s', at '%s' line %d"),
334 var, fname, lineno); 362 var, fname, lineno);
335 }
336 } 363 }
337 364
338 fclose (f); 365 fclose (f);
339 } 366 }
340 else 367 else
411 (*i)->print (); 438 (*i)->print ();
412 439
413 printf ("\n"); 440 printf ("\n");
414} 441}
415 442
416void 443configuration::configuration ()
417conf_node::print ()
418{ 444{
419 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n", 445 init ();
420 id,
421 id >> 8, id & 0xff,
422 compress ? 'Y' : 'N',
423 connectmode == C_ONDEMAND ? "ondemand" :
424 connectmode == C_NEVER ? "never" :
425 connectmode == C_ALWAYS ? "always" : "",
426 nodename,
427 hostname ? hostname : "",
428 hostname ? ":" : "",
429 hostname ? udp_port : 0
430 );
431} 446}
432 447
448configuration::~configuration ()
449{
450 cleanup ();
451}
452
453

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines