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.45 by pcg, Fri Aug 8 16:48:00 2008 UTC vs.
Revision 1.51 by pcg, Sat Jul 18 05:59:16 2009 UTC

92 92
93 return false; 93 return false;
94} 94}
95 95
96bool 96bool
97conf_node::can_direct (struct conf_node *other) 97conf_node::may_direct (struct conf_node *other)
98{ 98{
99 if (match_list (allow_direct, other->nodename)) 99 if (match_list (allow_direct, other->nodename))
100 return true; 100 return true;
101 101
102 if (match_list (deny_direct, other->nodename)) 102 if (match_list (deny_direct, other->nodename))
110{ 110{
111 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n", 111 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n",
112 id, 112 id,
113 id >> 8, id & 0xff, 113 id >> 8, id & 0xff,
114 compress ? 'Y' : 'N', 114 compress ? 'Y' : 'N',
115 connectmode == C_ONDEMAND ? "ondemand" : 115 connectmode == C_ONDEMAND ? "ondemand"
116 connectmode == C_NEVER ? "never" : 116 : connectmode == C_NEVER ? "never"
117 connectmode == C_ALWAYS ? "always" : "", 117 : connectmode == C_ALWAYS ? "always"
118 : connectmode == C_DISABLED ? "disabled"
119 : "",
118 nodename, 120 nodename,
119 hostname ? hostname : "", 121 hostname ? hostname : "",
120 hostname ? ":" : "", 122 hostname ? ":" : "",
121 hostname ? udp_port : 0 123 hostname ? udp_port : 0
122 ); 124 );
143void configuration::init () 145void configuration::init ()
144{ 146{
145 memset (this, 0, sizeof (*this)); 147 memset (this, 0, sizeof (*this));
146 148
147 mtu = DEFAULT_MTU; 149 mtu = DEFAULT_MTU;
150 nfmark = 0;
148 rekey = DEFAULT_REKEY; 151 rekey = DEFAULT_REKEY;
149 keepalive = DEFAULT_KEEPALIVE; 152 keepalive = DEFAULT_KEEPALIVE;
150 llevel = L_INFO; 153 llevel = L_INFO;
151 ip_proto = IPPROTO_GRE; 154 ip_proto = IPPROTO_GRE;
152#if ENABLE_ICMP 155#if ENABLE_ICMP
182 if (rsa_key) 185 if (rsa_key)
183 RSA_free (rsa_key); 186 RSA_free (rsa_key);
184 187
185 rsa_key = 0; 188 rsa_key = 0;
186 189
187 free (pidfilename); pidfilename = 0; 190 free (pidfilename); pidfilename = 0;
188 free (ifname); ifname = 0; 191 free (ifname); ifname = 0;
189#if ENABLE_HTTP_PROXY 192#if ENABLE_HTTP_PROXY
190 free (proxy_host); proxy_host = 0; 193 free (proxy_host); proxy_host = 0;
191 free (proxy_auth); proxy_auth = 0; 194 free (proxy_auth); proxy_auth = 0;
192#endif 195#endif
193#if ENABLE_DNS 196#if ENABLE_DNS
194 free (dns_forw_host); dns_forw_host = 0; 197 free (dns_forw_host); dns_forw_host = 0;
195#endif 198#endif
199 free (script_if_up); script_if_up = 0;
200 free (script_node_up); script_node_up = 0;
201 free (script_node_change); script_node_change = 0;
202 free (script_node_down); script_node_down = 0;
196} 203}
197 204
198void 205void
199configuration::clear () 206configuration::clear ()
200{ 207{
328 conf.rekey = atoi (val); 335 conf.rekey = atoi (val);
329 else if (!strcmp (var, "keepalive")) 336 else if (!strcmp (var, "keepalive"))
330 conf.keepalive = atoi (val); 337 conf.keepalive = atoi (val);
331 else if (!strcmp (var, "mtu")) 338 else if (!strcmp (var, "mtu"))
332 conf.mtu = atoi (val); 339 conf.mtu = atoi (val);
340 else if (!strcmp (var, "nfmark"))
341 conf.nfmark = atoi (val);
333 else if (!strcmp (var, "if-up")) 342 else if (!strcmp (var, "if-up"))
334 free (conf.script_if_up), conf.script_if_up = strdup (val); 343 free (conf.script_if_up), conf.script_if_up = strdup (val);
335 else if (!strcmp (var, "node-up")) 344 else if (!strcmp (var, "node-up"))
336 free (conf.script_node_up), conf.script_node_up = strdup (val); 345 free (conf.script_node_up), conf.script_node_up = strdup (val);
346 else if (!strcmp (var, "node-change"))
347 free (conf.script_node_change), conf.script_node_change = strdup (val);
337 else if (!strcmp (var, "node-down")) 348 else if (!strcmp (var, "node-down"))
338 free (conf.script_node_down), conf.script_node_down = strdup (val); 349 free (conf.script_node_down), conf.script_node_down = strdup (val);
339 else if (!strcmp (var, "pid-file")) 350 else if (!strcmp (var, "pid-file"))
340 free (conf.pidfilename), conf.pidfilename = strdup (val); 351 free (conf.pidfilename), conf.pidfilename = strdup (val);
341 else if (!strcmp (var, "dns-forw-host")) 352 else if (!strcmp (var, "dns-forw-host"))
475 else if (!strcmp (var, "deny-direct")) 486 else if (!strcmp (var, "deny-direct"))
476 node->deny_direct.push_back (strdup (val)); 487 node->deny_direct.push_back (strdup (val));
477 else if (!strcmp (var, "max-ttl")) 488 else if (!strcmp (var, "max-ttl"))
478 node->max_ttl = atof (val); 489 node->max_ttl = atof (val);
479 else if (!strcmp (var, "max-queue")) 490 else if (!strcmp (var, "max-queue"))
480 {
481 node->max_queue = atoi (val); 491 node->max_queue = atoi (val);
482
483 if (node->max_queue < 1)
484 node->max_queue = 1;
485 }
486 492
487 // unknown or misplaced 493 // unknown or misplaced
488 else 494 else
489 return _("unknown configuration directive. (ignored)"); 495 return _("unknown configuration directive. (ignored)");
490 496
491 return 0; 497 return 0;
498}
499
500void conf_node::finalise ()
501{
502 if (max_queue < 1)
503 {
504 slog (L_WARN, _("%s: max-queue value invalid, setting it to 1."), nodename);
505 max_queue = 1;
506 }
507
508 if (routerprio > 1 && (connectmode != C_ALWAYS && connectmode != C_DISABLED))
509 {
510 //slog (L_WARN, _("%s: has non-zero router-priority but either 'never' or 'ondemand' as connectmode, setting it to 'always'."), nodename);
511 connectmode = C_ALWAYS;
512 }
492} 513}
493 514
494void configuration_parser::parse_argv () 515void configuration_parser::parse_argv ()
495{ 516{
496 for (int i = 0; i < argc; ++i) 517 for (int i = 0; i < argc; ++i)
601 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode); 622 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode);
602 exit (EXIT_FAILURE); 623 exit (EXIT_FAILURE);
603 } 624 }
604 625
605 free (fname); 626 free (fname);
627
628 for (configuration::node_vector::iterator i = conf.nodes.begin(); i != conf.nodes.end(); ++i)
629 (*i)->finalise ();
606} 630}
607 631
608char *configuration::config_filename (const char *name, const char *dflt) 632char *configuration::config_filename (const char *name, const char *dflt)
609{ 633{
610 char *fname; 634 char *fname;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines