… | |
… | |
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 | { |
… | |
… | |
432 | } |
456 | } |
433 | else if (!strcmp (var, "enable-rawip")) |
457 | else if (!strcmp (var, "enable-rawip")) |
434 | { |
458 | { |
435 | u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; |
459 | u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; |
436 | } |
460 | } |
|
|
461 | else if (!strcmp (var, "allow-direct")) |
|
|
462 | node->allow_direct.push_back (strdup (val)); |
|
|
463 | else if (!strcmp (var, "deny-direct")) |
|
|
464 | node->deny_direct.push_back (strdup (val)); |
437 | |
465 | |
438 | // unknown or misplaced |
466 | // unknown or misplaced |
439 | else |
467 | else |
440 | return _("unknown configuration directive. (ignored)"); |
468 | return _("unknown configuration directive. (ignored)"); |
441 | |
469 | |