… | |
… | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with gvpe; if not, write to the Free Software |
18 | along with gvpe; if not, write to the Free Software |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ |
20 | */ |
21 | |
21 | |
22 | #include "config.h" |
22 | #include "config.h" |
23 | |
23 | |
24 | #include <cstdio> |
24 | #include <cstdio> |
… | |
… | |
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 | if (protocol & PROT_DNSv4 ) return "dns"; |
70 | |
70 | |
71 | return "<unknown>"; |
71 | return "<unknown>"; |
|
|
72 | } |
|
|
73 | |
|
|
74 | static bool |
|
|
75 | match_list (const vector<const char *> &list, const char *str) |
|
|
76 | { |
|
|
77 | for (vector<const char *>::const_iterator i = list.end (); i-- > list.begin (); ) |
|
|
78 | if ((*i)[0] == '*' && !(*i)[1]) |
|
|
79 | return true; |
|
|
80 | else if (!strcmp (*i, str)) |
|
|
81 | return true; |
|
|
82 | |
|
|
83 | return false; |
|
|
84 | } |
|
|
85 | |
|
|
86 | bool |
|
|
87 | conf_node::can_direct (struct conf_node *other) |
|
|
88 | { |
|
|
89 | if (match_list (allow_direct, other->nodename)) |
|
|
90 | return true; |
|
|
91 | |
|
|
92 | if (match_list (deny_direct, other->nodename)) |
|
|
93 | return false; |
|
|
94 | |
|
|
95 | return true; |
72 | } |
96 | } |
73 | |
97 | |
74 | void |
98 | void |
75 | conf_node::print () |
99 | conf_node::print () |
76 | { |
100 | { |
… | |
… | |
123 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
147 | default_node.tcp_port = DEFAULT_UDPPORT; // ehrm |
124 | default_node.connectmode = conf_node::C_ALWAYS; |
148 | default_node.connectmode = conf_node::C_ALWAYS; |
125 | default_node.compress = true; |
149 | default_node.compress = true; |
126 | default_node.protocols = 0; |
150 | default_node.protocols = 0; |
127 | default_node.max_retry = DEFAULT_MAX_RETRY; |
151 | default_node.max_retry = DEFAULT_MAX_RETRY; |
|
|
152 | default_node.max_ttl = DEFAULT_MAX_TTL; |
|
|
153 | default_node.max_queue = DEFAULT_MAX_QUEUE; |
128 | default_node.if_up_data = strdup (""); |
154 | default_node.if_up_data = strdup (""); |
129 | |
155 | |
130 | #if ENABLE_DNS |
156 | #if ENABLE_DNS |
131 | default_node.dns_port = 0; // default is 0 == client |
157 | default_node.dns_port = 0; // default is 0 == client |
132 | |
158 | |
… | |
… | |
432 | } |
458 | } |
433 | else if (!strcmp (var, "enable-rawip")) |
459 | else if (!strcmp (var, "enable-rawip")) |
434 | { |
460 | { |
435 | u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; |
461 | u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; |
436 | } |
462 | } |
|
|
463 | else if (!strcmp (var, "allow-direct")) |
|
|
464 | node->allow_direct.push_back (strdup (val)); |
|
|
465 | else if (!strcmp (var, "deny-direct")) |
|
|
466 | node->deny_direct.push_back (strdup (val)); |
|
|
467 | else if (!strcmp (var, "max-ttl")) |
|
|
468 | node->max_ttl = atof (val); |
|
|
469 | else if (!strcmp (var, "max-queue")) |
|
|
470 | node->max_queue = atoi (val); |
437 | |
471 | |
438 | // unknown or misplaced |
472 | // unknown or misplaced |
439 | else |
473 | else |
440 | return _("unknown configuration directive. (ignored)"); |
474 | return _("unknown configuration directive. (ignored)"); |
441 | |
475 | |