From: erik.kapfer Date: Fri, 30 Nov 2018 09:51:51 +0000 (+0100) Subject: OpenVPN: Calculate CIDR to DDN notation for RW X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fovpnrw_cidr2ddn;p=people%2Fummeegge%2Fipfire-2.x.git OpenVPN: Calculate CIDR to DDN notation for RW Fixes #11823 Patches enables CIDR and dotted-decimal notation for "OpenVPN subnet:" entries in "Global settings". --- diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 976300fc72..b3d9b9d267 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -245,6 +245,7 @@ sub pkiconfigcheck sub writeserverconf { my %sovpnsettings = (); my @temp = (); + my @tempovpnsubnet = (); &General::readhash("${General::swroot}/ovpn/settings", \%sovpnsettings); &read_routepushfile; @@ -267,8 +268,16 @@ sub writeserverconf { print CONF "cert ${General::swroot}/ovpn/certs/servercert.pem\n"; print CONF "key ${General::swroot}/ovpn/certs/serverkey.pem\n"; print CONF "dh ${General::swroot}/ovpn/ca/$cgiparams{'DH_NAME'}\n"; - my @tempovpnsubnet = split("\/",$sovpnsettings{'DOVPN_SUBNET'}); - print CONF "server $tempovpnsubnet[0] $tempovpnsubnet[1]\n"; + # ovpn subnet calculate prefix to netmask if needed + if ($sovpnsettings{'DOVPN_SUBNET'} ne '') { + my ($ip,$subnet) = split(/\//,"$vpnsettings{'DOVPN_SUBNET'}"); + if (&Network::check_prefix($subnet)) { + $subnet = &Network::convert_prefix2netmask($subnet); + print CONF "server $ip $subnet\n"; + } else { + print CONF "server $ip $subnet\n"; + } + } #print CONF "push \"route $netsettings{'GREEN_NETADDRESS'} $netsettings{'GREEN_NETMASK'}\"\n"; # Check if we are using mssfix, fragment and set the corretct mtu of 1500.