public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Erik Kapfer <erik.kapfer@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH] OpenVPN: Calculate CIDR to DDN notation for RW
Date: Tue, 04 Dec 2018 08:34:02 +0100	[thread overview]
Message-ID: <20181204073402.27898-1-erik.kapfer@ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]

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.
-- 
2.12.2


             reply	other threads:[~2018-12-04  7:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04  7:34 Erik Kapfer [this message]
2018-12-05  7:14 ` [PATCH v2] " Erik Kapfer
2018-12-11  8:40   ` ummeegge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181204073402.27898-1-erik.kapfer@ipfire.org \
    --to=erik.kapfer@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox