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.22 by pcg, Thu Jan 29 18:55:10 2004 UTC vs.
Revision 1.26 by pcg, Wed May 12 13:32:13 2004 UTC

44#include "util.h" 44#include "util.h"
45 45
46char *confbase; 46char *confbase;
47char *thisnode; 47char *thisnode;
48char *identname; 48char *identname;
49char *pidfilename;
50 49
51struct configuration conf; 50struct configuration conf;
52 51
53u8 best_protocol (u8 protset) 52u8 best_protocol (u8 protset)
54{ 53{
55 if (protset & PROT_IPv4 ) return PROT_IPv4; 54 if (protset & PROT_IPv4 ) return PROT_IPv4;
56 if (protset & PROT_ICMPv4) return PROT_ICMPv4; 55 if (protset & PROT_ICMPv4) return PROT_ICMPv4;
57 if (protset & PROT_UDPv4 ) return PROT_UDPv4; 56 if (protset & PROT_UDPv4 ) return PROT_UDPv4;
58 if (protset & PROT_TCPv4 ) return PROT_TCPv4; 57 if (protset & PROT_TCPv4 ) return PROT_TCPv4;
58 if (protset & PROT_DNSv4 ) return PROT_DNSv4;
59 59
60 return 0; 60 return 0;
61} 61}
62 62
63const char *strprotocol (u8 protocol) 63const char *strprotocol (u8 protocol)
64{ 64{
65 if (protocol & PROT_IPv4 ) return "rawip"; 65 if (protocol & PROT_IPv4 ) return "rawip";
66 if (protocol & PROT_ICMPv4) return "icmp"; 66 if (protocol & PROT_ICMPv4) return "icmp";
67 if (protocol & PROT_UDPv4 ) return "udp"; 67 if (protocol & PROT_UDPv4 ) return "udp";
68 if (protocol & PROT_TCPv4 ) return "tcp"; 68 if (protocol & PROT_TCPv4 ) return "tcp";
69 if (protocol & PROT_DNSv4 ) return "dns";
69 70
70 return "<unknown>"; 71 return "<unknown>";
71} 72}
72 73
73void 74void
108#if ENABLE_ICMP 109#if ENABLE_ICMP
109 icmp_type = ICMP_ECHOREPLY; 110 icmp_type = ICMP_ECHOREPLY;
110#endif 111#endif
111 112
112 default_node.udp_port = DEFAULT_UDPPORT; 113 default_node.udp_port = DEFAULT_UDPPORT;
113 default_node.tcp_port = DEFAULT_UDPPORT; 114 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
114 default_node.connectmode = conf_node::C_ALWAYS; 115 default_node.connectmode = conf_node::C_ALWAYS;
115 default_node.compress = true; 116 default_node.compress = true;
116 default_node.protocols = PROT_UDPv4; 117 default_node.protocols = PROT_UDPv4;
118
119 conf.pidfilename = strdup (LOCALSTATEDIR "/run/vped.pid");
117} 120}
118 121
119void configuration::cleanup() 122void configuration::cleanup()
120{ 123{
121 if (rsa_key) 124 if (rsa_key)
122 RSA_free (rsa_key); 125 RSA_free (rsa_key);
123 126
124 rsa_key = 0; 127 rsa_key = 0;
125 128
129 free (pidfilename); pidfilename = 0;
126 free (ifname); ifname = 0; 130 free (ifname); ifname = 0;
127#if ENABLE_HTTP_PROXY 131#if ENABLE_HTTP_PROXY
128 free (proxy_host); proxy_host = 0; 132 free (proxy_host); proxy_host = 0;
129 free (proxy_auth); proxy_auth = 0; 133 free (proxy_auth); proxy_auth = 0;
130#endif 134#endif
131} 135}
132 136
133void 137void
134configuration::clear_config () 138configuration::clear_config ()
277 } 281 }
278 282
279 free (fname); 283 free (fname);
280 } 284 }
281 285
282 if (!::thisnode || !strcmp (node->nodename, ::thisnode)) 286 if (::thisnode && !strcmp (node->nodename, ::thisnode))
283 thisnode = node; 287 thisnode = node;
284 } 288 }
285 else if (!strcmp (var, "private-key")) 289 else if (!strcmp (var, "private-key"))
286 prikeyfile = strdup (val); 290 free (prikeyfile), prikeyfile = strdup (val);
287 else if (!strcmp (var, "ifpersist")) 291 else if (!strcmp (var, "ifpersist"))
288 { 292 {
289 parse_bool (ifpersist, "ifpersist", true, false); 293 parse_bool (ifpersist, "ifpersist", true, false);
290 } 294 }
291 else if (!strcmp (var, "ifname")) 295 else if (!strcmp (var, "ifname"))
292 ifname = strdup (val); 296 free (ifname), ifname = strdup (val);
293 else if (!strcmp (var, "rekey")) 297 else if (!strcmp (var, "rekey"))
294 rekey = atoi (val); 298 rekey = atoi (val);
295 else if (!strcmp (var, "keepalive")) 299 else if (!strcmp (var, "keepalive"))
296 keepalive = atoi (val); 300 keepalive = atoi (val);
297 else if (!strcmp (var, "mtu")) 301 else if (!strcmp (var, "mtu"))
298 mtu = atoi (val); 302 mtu = atoi (val);
299 else if (!strcmp (var, "if-up")) 303 else if (!strcmp (var, "if-up"))
300 script_if_up = strdup (val); 304 free (script_if_up), script_if_up = strdup (val);
301 else if (!strcmp (var, "node-up")) 305 else if (!strcmp (var, "node-up"))
302 script_node_up = strdup (val); 306 free (script_node_up), script_node_up = strdup (val);
303 else if (!strcmp (var, "node-down")) 307 else if (!strcmp (var, "node-down"))
304 script_node_down = strdup (val); 308 free (script_node_down), script_node_down = strdup (val);
309 else if (!strcmp (var, "pid-file"))
310 free (pidfilename), pidfilename = strdup (val);
305 else if (!strcmp (var, "http-proxy-host")) 311 else if (!strcmp (var, "http-proxy-host"))
306 { 312 {
307#if ENABLE_HTTP_PROXY 313#if ENABLE_HTTP_PROXY
308 proxy_host = strdup (val); 314 free (proxy_host), proxy_host = strdup (val);
309#endif 315#endif
310 } 316 }
311 else if (!strcmp (var, "http-proxy-port")) 317 else if (!strcmp (var, "http-proxy-port"))
312 { 318 {
313#if ENABLE_HTTP_PROXY 319#if ENABLE_HTTP_PROXY
321#endif 327#endif
322 } 328 }
323 329
324 /* node-specific, non-defaultable */ 330 /* node-specific, non-defaultable */
325 else if (node != &default_node && !strcmp (var, "hostname")) 331 else if (node != &default_node && !strcmp (var, "hostname"))
326 {
327 free (node->hostname);
328 node->hostname = strdup (val); 332 free (node->hostname), node->hostname = strdup (val);
329 }
330 333
331 /* node-specific, defaultable */ 334 /* node-specific, defaultable */
332 else if (!strcmp (var, "udp-port")) 335 else if (!strcmp (var, "udp-port"))
333 node->udp_port = atoi (val); 336 node->udp_port = atoi (val);
334 else if (!strcmp (var, "tcp-port")) 337 else if (!strcmp (var, "tcp-port"))
335 node->tcp_port = atoi (val); 338 node->tcp_port = atoi (val);
339 else if (!strcmp (var, "dns-port"))
340 node->dns_port = atoi (val);
336 else if (!strcmp (var, "router-priority")) 341 else if (!strcmp (var, "router-priority"))
337 node->routerprio = atoi (val); 342 node->routerprio = atoi (val);
338 else if (!strcmp (var, "connect")) 343 else if (!strcmp (var, "connect"))
339 { 344 {
340 if (!strcmp (val, "ondemand")) 345 if (!strcmp (val, "ondemand"))
369 { 374 {
370#if ENABLE_ICMP 375#if ENABLE_ICMP
371 u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v; 376 u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v;
372#endif 377#endif
373 } 378 }
379 else if (!strcmp (var, "enable-dns"))
380 {
381#if ENABLE_DNS
382 u8 v; parse_bool (v, "enable-dns" , PROT_DNSv4, 0); node->protocols = (node->protocols & ~PROT_DNSv4) | v;
383#endif
384 }
374 else if (!strcmp (var, "enable-udp")) 385 else if (!strcmp (var, "enable-udp"))
375 { 386 {
376 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 387 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
377 } 388 }
378 else if (!strcmp (var, "enable-rawip")) 389 else if (!strcmp (var, "enable-rawip"))
379 { 390 {;
380 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; 391 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v;
381 } 392 }
382 393
383 // unknown or misplaced 394 // unknown or misplaced
384 else 395 else
421 432
422 if (need_keys) 433 if (need_keys)
423 exit (EXIT_FAILURE); 434 exit (EXIT_FAILURE);
424 } 435 }
425 436
437 if (need_keys && ::thisnode
426 if (need_keys && rsa_key && thisnode && thisnode->rsa_key) 438 && rsa_key && thisnode && thisnode->rsa_key)
427 if (BN_cmp (rsa_key->n, thisnode->rsa_key->n) != 0 439 if (BN_cmp (rsa_key->n, thisnode->rsa_key->n) != 0
428 || BN_cmp (rsa_key->e, thisnode->rsa_key->e) != 0) 440 || BN_cmp (rsa_key->e, thisnode->rsa_key->e) != 0)
429 { 441 {
430 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode); 442 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode);
431 exit (EXIT_FAILURE); 443 exit (EXIT_FAILURE);
473 printf ("\n"); 485 printf ("\n");
474} 486}
475 487
476configuration::configuration () 488configuration::configuration ()
477{ 489{
490 asprintf (&confbase, "%s/vpe", CONFDIR);
491
478 init (); 492 init ();
479} 493}
480 494
481configuration::~configuration () 495configuration::~configuration ()
482{ 496{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines