Fixes #11823
Patches enables CIDR and dotted-decimal notation for "OpenVPN subnet:" entries in "Global settings". --- html/cgi-bin/ovpnmain.cgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 976300fc7..7fd3e1d67 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.