--- gvpe/src/conf.C 2004/05/10 20:13:09 1.25 +++ gvpe/src/conf.C 2005/03/05 15:48:54 1.32 @@ -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 */ @@ -95,12 +97,14 @@ free (nodename); free (hostname); +#if ENABLE_DNS + free (domain); + free (dns_hostname); +#endif } void configuration::init () { - asprintf (&confbase, "%s/vpe", CONFDIR); - memset (this, 0, sizeof (*this)); mtu = DEFAULT_MTU; @@ -116,9 +120,15 @@ 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_port = 53; +#endif - conf.pidfilename = strdup (LOCALSTATEDIR "/run/vped.pid"); + conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); } void configuration::cleanup() @@ -128,11 +138,14 @@ rsa_key = 0; - free (pidfilename); pidfilename = 0; - free (ifname); ifname = 0; + free (pidfilename); pidfilename = 0; + free (ifname); ifname = 0; #if ENABLE_HTTP_PROXY - free (proxy_host); proxy_host = 0; - free (proxy_auth); proxy_auth = 0; + free (proxy_host); proxy_host = 0; + free (proxy_auth); proxy_auth = 0; +#endif +#if ENABLE_DNS + free (dns_forw_host); dns_forw_host = 0; #endif } @@ -167,7 +180,7 @@ clear_config (); - asprintf (&fname, "%s/vped.conf", confbase); + asprintf (&fname, "%s/gvpe.conf", confbase); f = fopen (fname, "r"); if (f) @@ -310,6 +323,12 @@ free (script_node_down), script_node_down = strdup (val); else if (!strcmp (var, "pid-file")) free (pidfilename), pidfilename = strdup (val); +#if ENABLE_DNS + else if (!strcmp (var, "dns-forw-host")) + free (dns_forw_host), dns_forw_host = strdup (val); + else if (!strcmp (var, "dns-forw-port")) + dns_forw_port = atoi (val); +#endif else if (!strcmp (var, "http-proxy-host")) { #if ENABLE_HTTP_PROXY @@ -338,10 +357,22 @@ node->udp_port = atoi (val); else if (!strcmp (var, "tcp-port")) node->tcp_port = atoi (val); +#if ENABLE_DNS + else if (!strcmp (var, "dns-hostname")) + free (node->dns_hostname), node->dns_hostname = strdup (val); else if (!strcmp (var, "dns-port")) node->dns_port = atoi (val); +#endif + else if (!strcmp (var, "dns-domain")) + { +#if ENABLE_DNS + free (node->domain), node->domain = strdup (val); +#endif + } else if (!strcmp (var, "router-priority")) node->routerprio = atoi (val); + else if (!strcmp (var, "max-retry")) + node->max_retry = atoi (val); else if (!strcmp (var, "connect")) { if (!strcmp (val, "ondemand")) @@ -354,8 +385,8 @@ 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"), - var, fname, lineno); + _("illegal value for 'connectmode', use one of 'ondemand', 'never', 'always' or 'disabled', at '%s' line %d"), + var, fname, lineno); } else if (!strcmp (var, "inherit-tos")) { @@ -389,7 +420,7 @@ u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; } else if (!strcmp (var, "enable-rawip")) - {; + { u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; } @@ -489,6 +520,8 @@ configuration::configuration () { + asprintf (&confbase, "%s/gvpe", CONFDIR); + init (); }