… | |
… | |
51 | char *identname; |
51 | char *identname; |
52 | char *pidfilename; |
52 | char *pidfilename; |
53 | |
53 | |
54 | struct configuration conf; |
54 | struct configuration conf; |
55 | |
55 | |
|
|
56 | u8 best_protocol (u8 protset) |
|
|
57 | { |
|
|
58 | if (protset & PROT_IPv4 ) return PROT_IPv4; |
|
|
59 | if (protset & PROT_UDPv4) return PROT_UDPv4; |
|
|
60 | if (protset & PROT_TCPv4) return PROT_TCPv4; |
|
|
61 | |
|
|
62 | return 0; |
|
|
63 | } |
|
|
64 | |
|
|
65 | const char *strprotocol (u8 protocol) |
|
|
66 | { |
|
|
67 | if (protocol & PROT_IPv4 ) return "rawip"; |
|
|
68 | if (protocol & PROT_UDPv4) return "udp"; |
|
|
69 | |
|
|
70 | return "<unknown>"; |
|
|
71 | } |
|
|
72 | |
56 | configuration::configuration () |
73 | configuration::configuration () |
57 | { |
74 | { |
58 | init (); |
75 | init (); |
59 | } |
76 | } |
60 | |
77 | |
… | |
… | |
71 | keepalive = DEFAULT_KEEPALIVE; |
88 | keepalive = DEFAULT_KEEPALIVE; |
72 | llevel = L_INFO; |
89 | llevel = L_INFO; |
73 | ip_proto = IPPROTO_GRE; |
90 | ip_proto = IPPROTO_GRE; |
74 | |
91 | |
75 | default_node.udp_port = DEFAULT_UDPPORT; |
92 | default_node.udp_port = DEFAULT_UDPPORT; |
|
|
93 | default_node.tcp_port = DEFAULT_UDPPORT; |
76 | default_node.connectmode = conf_node::C_ALWAYS; |
94 | default_node.connectmode = conf_node::C_ALWAYS; |
77 | default_node.compress = true; |
95 | default_node.compress = true; |
78 | default_node.protocols = PROT_UDPv4; |
96 | default_node.protocols = PROT_UDPv4; |
79 | } |
97 | } |
80 | |
98 | |
… | |
… | |
264 | } |
282 | } |
265 | |
283 | |
266 | /* node-specific, defaultable */ |
284 | /* node-specific, defaultable */ |
267 | else if (!strcmp (var, "udp-port")) |
285 | else if (!strcmp (var, "udp-port")) |
268 | node->udp_port = atoi (val); |
286 | node->udp_port = atoi (val); |
|
|
287 | else if (!strcmp (var, "tcp-port")) |
|
|
288 | node->tcp_port = atoi (val); |
269 | else if (!strcmp (var, "router-priority")) |
289 | else if (!strcmp (var, "router-priority")) |
270 | node->routerprio = atoi (val); |
290 | node->routerprio = atoi (val); |
271 | else if (!strcmp (var, "connect")) |
291 | else if (!strcmp (var, "connect")) |
272 | { |
292 | { |
273 | if (!strcmp (val, "ondemand")) |
293 | if (!strcmp (val, "ondemand")) |
… | |
… | |
290 | else if (!strcmp (var, "compress")) |
310 | else if (!strcmp (var, "compress")) |
291 | { |
311 | { |
292 | parse_bool (node->compress, "compress", true, false); |
312 | parse_bool (node->compress, "compress", true, false); |
293 | } |
313 | } |
294 | // all these bool options really really cost a lot of executable size! |
314 | // all these bool options really really cost a lot of executable size! |
|
|
315 | else if (!strcmp (var, "enable-tcp")) |
|
|
316 | { |
|
|
317 | u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; |
|
|
318 | } |
295 | else if (!strcmp (var, "enable-udp")) |
319 | else if (!strcmp (var, "enable-udp")) |
296 | { |
320 | { |
297 | u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; |
321 | u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; |
298 | } |
322 | } |
299 | else if (!strcmp (var, "enable-rawip")) |
323 | else if (!strcmp (var, "enable-rawip")) |