… | |
… | |
53 | |
53 | |
54 | struct configuration conf; |
54 | struct configuration conf; |
55 | |
55 | |
56 | u8 best_protocol (u8 protset) |
56 | u8 best_protocol (u8 protset) |
57 | { |
57 | { |
58 | if (protset & PROT_IPv4) |
58 | if (protset & PROT_IPv4 ) return PROT_IPv4; |
59 | return PROT_IPv4; |
59 | if (protset & PROT_UDPv4) return PROT_UDPv4; |
|
|
60 | if (protset & PROT_TCPv4) return PROT_TCPv4; |
60 | |
61 | |
61 | return PROT_UDPv4; |
62 | return 0; |
62 | } |
63 | } |
63 | |
64 | |
64 | const char *strprotocol (u8 protocol) |
65 | const char *strprotocol (u8 protocol) |
65 | { |
66 | { |
66 | if (protocol & PROT_IPv4 ) return "rawip"; |
67 | if (protocol & PROT_IPv4 ) return "rawip"; |
67 | if (protocol & PROT_UDPv4) return "udp"; |
68 | if (protocol & PROT_UDPv4) return "udp"; |
|
|
69 | if (protocol & PROT_TCPv4) return "tcp"; |
68 | |
70 | |
69 | return "<unknown>"; |
71 | return "<unknown>"; |
70 | } |
72 | } |
71 | |
73 | |
72 | configuration::configuration () |
74 | configuration::configuration () |
… | |
… | |
87 | keepalive = DEFAULT_KEEPALIVE; |
89 | keepalive = DEFAULT_KEEPALIVE; |
88 | llevel = L_INFO; |
90 | llevel = L_INFO; |
89 | ip_proto = IPPROTO_GRE; |
91 | ip_proto = IPPROTO_GRE; |
90 | |
92 | |
91 | default_node.udp_port = DEFAULT_UDPPORT; |
93 | default_node.udp_port = DEFAULT_UDPPORT; |
|
|
94 | default_node.tcp_port = DEFAULT_UDPPORT; |
92 | default_node.connectmode = conf_node::C_ALWAYS; |
95 | default_node.connectmode = conf_node::C_ALWAYS; |
93 | default_node.compress = true; |
96 | default_node.compress = true; |
94 | default_node.protocols = PROT_UDPv4; |
97 | default_node.protocols = PROT_UDPv4; |
95 | } |
98 | } |
96 | |
99 | |
… | |
… | |
280 | } |
283 | } |
281 | |
284 | |
282 | /* node-specific, defaultable */ |
285 | /* node-specific, defaultable */ |
283 | else if (!strcmp (var, "udp-port")) |
286 | else if (!strcmp (var, "udp-port")) |
284 | node->udp_port = atoi (val); |
287 | node->udp_port = atoi (val); |
|
|
288 | else if (!strcmp (var, "tcp-port")) |
|
|
289 | node->tcp_port = atoi (val); |
285 | else if (!strcmp (var, "router-priority")) |
290 | else if (!strcmp (var, "router-priority")) |
286 | node->routerprio = atoi (val); |
291 | node->routerprio = atoi (val); |
287 | else if (!strcmp (var, "connect")) |
292 | else if (!strcmp (var, "connect")) |
288 | { |
293 | { |
289 | if (!strcmp (val, "ondemand")) |
294 | if (!strcmp (val, "ondemand")) |
… | |
… | |
306 | else if (!strcmp (var, "compress")) |
311 | else if (!strcmp (var, "compress")) |
307 | { |
312 | { |
308 | parse_bool (node->compress, "compress", true, false); |
313 | parse_bool (node->compress, "compress", true, false); |
309 | } |
314 | } |
310 | // all these bool options really really cost a lot of executable size! |
315 | // all these bool options really really cost a lot of executable size! |
|
|
316 | else if (!strcmp (var, "enable-tcp")) |
|
|
317 | { |
|
|
318 | #if ENABLE_TCP |
|
|
319 | u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; |
|
|
320 | #endif |
|
|
321 | } |
311 | else if (!strcmp (var, "enable-udp")) |
322 | else if (!strcmp (var, "enable-udp")) |
312 | { |
323 | { |
313 | u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; |
324 | u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; |
314 | } |
325 | } |
315 | else if (!strcmp (var, "enable-rawip")) |
326 | else if (!strcmp (var, "enable-rawip")) |