--- gvpe/src/conf.C 2005/03/01 04:38:21 1.28 +++ gvpe/src/conf.C 2005/03/23 17:03:58 1.38 @@ -1,8 +1,10 @@ /* conf.c -- configuration code - Copyright (C) 2003-2004 Marc Lehmann + Copyright (C) 2003-2005 Marc Lehmann - This program is free software; you can redistribute it and/or modify + This file is part of GVPE. + + GVPE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,7 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software + along with gvpe; if not, write to the Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -37,8 +39,6 @@ #include #include -#include "gettext.h" - #include "conf.h" #include "slog.h" #include "util.h" @@ -95,7 +95,10 @@ free (nodename); free (hostname); +#if ENABLE_DNS free (domain); + free (dns_hostname); +#endif } void configuration::init () @@ -115,9 +118,20 @@ default_node.tcp_port = DEFAULT_UDPPORT; // ehrm default_node.connectmode = conf_node::C_ALWAYS; default_node.compress = true; - default_node.protocols = PROT_UDPv4; + default_node.protocols = 0; default_node.max_retry = DEFAULT_MAX_RETRY; +#if ENABLE_DNS + default_node.dns_port = 0; // default is 0 == client + + dns_forw_host = strdup ("127.0.0.1"); + dns_forw_port = 53; + dns_timeout_factor = DEFAULT_DNS_TIMEOUT_FACTOR; + dns_send_interval = DEFAULT_DNS_SEND_INTERVAL; + dns_overlap_factor = DEFAULT_DNS_OVERLAP_FACTOR; + dns_max_outstanding = DEFAULT_DNS_MAX_OUTSTANDING; +#endif + conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); } @@ -151,8 +165,8 @@ init (); } -#define parse_bool(target,name,trueval,falseval) \ - if (!strcmp (val, "yes")) target = trueval; \ +#define parse_bool(target,name,trueval,falseval) do { \ + if (!strcmp (val, "yes")) target = trueval; \ else if (!strcmp (val, "no")) target = falseval; \ else if (!strcmp (val, "true")) target = trueval; \ else if (!strcmp (val, "false")) target = falseval; \ @@ -161,7 +175,8 @@ else \ slog (L_WARN, \ _("illegal value for '%s', only 'yes|true|on' or 'no|false|off' allowed, at '%s' line %d"), \ - name, var, fname, lineno); + name, var, fname, lineno); \ +} while (0) void configuration::read_config (bool need_keys) { @@ -210,9 +225,9 @@ if (!val || val[0] == '#') { slog (L_WARN, - _("no value for variable `%s', at '%s' line %d"), + _("no value for variable `%s', at '%s' line %d, skipping."), var, fname, lineno); - break; + continue; } if (!strcmp (var, "on")) @@ -294,9 +309,7 @@ else if (!strcmp (var, "private-key")) free (prikeyfile), prikeyfile = strdup (val); else if (!strcmp (var, "ifpersist")) - { - parse_bool (ifpersist, "ifpersist", true, false); - } + parse_bool (ifpersist, "ifpersist", true, false); else if (!strcmp (var, "ifname")) free (ifname), ifname = strdup (val); else if (!strcmp (var, "rekey")) @@ -313,18 +326,42 @@ free (script_node_down), script_node_down = strdup (val); else if (!strcmp (var, "pid-file")) free (pidfilename), pidfilename = strdup (val); - else if (!strcmp (var, "dns-forwarder-host")) + else if (!strcmp (var, "dns-forw-host")) { #if ENABLE_DNS free (dns_forw_host), dns_forw_host = strdup (val); #endif } - else if (!strcmp (var, "dns-forwarder-port")) + else if (!strcmp (var, "dns-forw-port")) { #if ENABLE_DNS dns_forw_port = atoi (val); #endif } + else if (!strcmp (var, "dns-timeout-factor")) + { +#if ENABLE_DNS + dns_timeout_factor = atof (val); +#endif + } + else if (!strcmp (var, "dns-send-interval")) + { +#if ENABLE_DNS + dns_send_interval = atoi (val); +#endif + } + else if (!strcmp (var, "dns-overlap-factor")) + { +#if ENABLE_DNS + dns_overlap_factor = atof (val); +#endif + } + else if (!strcmp (var, "dns-max-outstanding")) + { +#if ENABLE_DNS + dns_max_outstanding = atoi (val); +#endif + } else if (!strcmp (var, "http-proxy-host")) { #if ENABLE_HTTP_PROXY @@ -353,6 +390,12 @@ node->udp_port = atoi (val); else if (!strcmp (var, "tcp-port")) node->tcp_port = atoi (val); + else if (!strcmp (var, "dns-hostname")) + { +#if ENABLE_DNS + free (node->dns_hostname), node->dns_hostname = strdup (val); +#endif + } else if (!strcmp (var, "dns-port")) { #if ENABLE_DNS @@ -381,17 +424,13 @@ node->connectmode = conf_node::C_DISABLED; else slog (L_WARN, - _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), + _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d, ignoring."), var, fname, lineno); } else if (!strcmp (var, "inherit-tos")) - { - parse_bool (node->inherit_tos, "inherit-tos", true, false); - } + parse_bool (node->inherit_tos, "inherit-tos", true, false); else if (!strcmp (var, "compress")) - { - parse_bool (node->compress, "compress", true, false); - } + parse_bool (node->compress, "compress", true, false); // all these bool options really really cost a lot of executable size! else if (!strcmp (var, "enable-tcp")) { @@ -423,7 +462,7 @@ // unknown or misplaced else slog (L_WARN, - _("unknown or misplaced variable `%s', at '%s' line %d"), + _("unknown or misplaced variable `%s', at '%s' line %d, skipping."), var, fname, lineno); }