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.9 by pcg, Wed Apr 2 05:14:59 2003 UTC vs.
Revision 1.12 by pcg, Mon Apr 7 01:12:56 2003 UTC

64 64
65const char *strprotocol (u8 protocol) 65const char *strprotocol (u8 protocol)
66{ 66{
67 if (protocol & PROT_IPv4 ) return "rawip"; 67 if (protocol & PROT_IPv4 ) return "rawip";
68 if (protocol & PROT_UDPv4) return "udp"; 68 if (protocol & PROT_UDPv4) return "udp";
69 if (protocol & PROT_TCPv4) return "tcp";
69 70
70 return "<unknown>"; 71 return "<unknown>";
71} 72}
72 73
73configuration::configuration () 74void
75conf_node::print ()
74{ 76{
75 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 );
76} 89}
77 90
78configuration::~configuration () 91conf_node::~conf_node ()
79{ 92{
80 cleanup (); 93 if (rsa_key)
94 RSA_free (rsa_key);
95
96 free (nodename);
97 free (hostname);
81} 98}
82 99
83void configuration::init () 100void configuration::init ()
84{ 101{
85 memset (this, 0, sizeof (*this)); 102 memset (this, 0, sizeof (*this));
99void configuration::cleanup() 116void configuration::cleanup()
100{ 117{
101 if (rsa_key) 118 if (rsa_key)
102 RSA_free (rsa_key); 119 RSA_free (rsa_key);
103 120
104 free (ifname);
105
106 rsa_key = 0; 121 rsa_key = 0;
107 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
108} 128}
109 129
110void 130void
111configuration::clear_config () 131configuration::clear_config ()
112{ 132{
271 script_if_up = strdup (val); 291 script_if_up = strdup (val);
272 else if (!strcmp (var, "node-up")) 292 else if (!strcmp (var, "node-up"))
273 script_node_up = strdup (val); 293 script_node_up = strdup (val);
274 else if (!strcmp (var, "node-down")) 294 else if (!strcmp (var, "node-down"))
275 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
276 304
277 /* node-specific, non-defaultable */ 305 /* node-specific, non-defaultable */
278 else if (node != &default_node && !strcmp (var, "hostname")) 306 else if (node != &default_node && !strcmp (var, "hostname"))
279 { 307 {
280 free (node->hostname); 308 free (node->hostname);
312 parse_bool (node->compress, "compress", true, false); 340 parse_bool (node->compress, "compress", true, false);
313 } 341 }
314 // 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!
315 else if (!strcmp (var, "enable-tcp")) 343 else if (!strcmp (var, "enable-tcp"))
316 { 344 {
345#if ENABLE_TCP
317 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
318 } 348 }
319 else if (!strcmp (var, "enable-udp")) 349 else if (!strcmp (var, "enable-udp"))
320 { 350 {
321 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;
322 } 352 }
325 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;
326 } 356 }
327 357
328 // unknown or misplaced 358 // unknown or misplaced
329 else 359 else
330 {
331 slog (L_WARN, 360 slog (L_WARN,
332 _("unknown or misplaced variable `%s', at '%s' line %d"), 361 _("unknown or misplaced variable `%s', at '%s' line %d"),
333 var, fname, lineno); 362 var, fname, lineno);
334 }
335 } 363 }
336 364
337 fclose (f); 365 fclose (f);
338 } 366 }
339 else 367 else
410 (*i)->print (); 438 (*i)->print ();
411 439
412 printf ("\n"); 440 printf ("\n");
413} 441}
414 442
415void 443configuration::configuration ()
416conf_node::print ()
417{ 444{
418 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n", 445 init ();
419 id,
420 id >> 8, id & 0xff,
421 compress ? 'Y' : 'N',
422 connectmode == C_ONDEMAND ? "ondemand" :
423 connectmode == C_NEVER ? "never" :
424 connectmode == C_ALWAYS ? "always" : "",
425 nodename,
426 hostname ? hostname : "",
427 hostname ? ":" : "",
428 hostname ? udp_port : 0
429 );
430} 446}
431 447
448configuration::~configuration ()
449{
450 cleanup ();
451}
452
453

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines