… | |
… | |
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 | |
74 | configuration::configuration () |
74 | void |
|
|
75 | conf_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 | |
79 | configuration::~configuration () |
91 | conf_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 | |
84 | void configuration::init () |
100 | void configuration::init () |
85 | { |
101 | { |
86 | memset (this, 0, sizeof (*this)); |
102 | memset (this, 0, sizeof (*this)); |
… | |
… | |
100 | void configuration::cleanup() |
116 | void 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 | |
111 | void |
130 | void |
112 | configuration::clear_config () |
131 | configuration::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); |
… | |
… | |
328 | 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; |
329 | } |
356 | } |
330 | |
357 | |
331 | // unknown or misplaced |
358 | // unknown or misplaced |
332 | else |
359 | else |
333 | { |
|
|
334 | slog (L_WARN, |
360 | slog (L_WARN, |
335 | _("unknown or misplaced variable `%s', at '%s' line %d"), |
361 | _("unknown or misplaced variable `%s', at '%s' line %d"), |
336 | var, fname, lineno); |
362 | var, fname, lineno); |
337 | } |
|
|
338 | } |
363 | } |
339 | |
364 | |
340 | fclose (f); |
365 | fclose (f); |
341 | } |
366 | } |
342 | else |
367 | else |
… | |
… | |
413 | (*i)->print (); |
438 | (*i)->print (); |
414 | |
439 | |
415 | printf ("\n"); |
440 | printf ("\n"); |
416 | } |
441 | } |
417 | |
442 | |
418 | void |
443 | configuration::configuration () |
419 | conf_node::print () |
|
|
420 | { |
444 | { |
421 | printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n", |
445 | init (); |
422 | id, |
|
|
423 | id >> 8, id & 0xff, |
|
|
424 | compress ? 'Y' : 'N', |
|
|
425 | connectmode == C_ONDEMAND ? "ondemand" : |
|
|
426 | connectmode == C_NEVER ? "never" : |
|
|
427 | connectmode == C_ALWAYS ? "always" : "", |
|
|
428 | nodename, |
|
|
429 | hostname ? hostname : "", |
|
|
430 | hostname ? ":" : "", |
|
|
431 | hostname ? udp_port : 0 |
|
|
432 | ); |
|
|
433 | } |
446 | } |
434 | |
447 | |
|
|
448 | configuration::~configuration () |
|
|
449 | { |
|
|
450 | cleanup (); |
|
|
451 | } |
|
|
452 | |
|
|
453 | |