From patchwork Tue Dec 4 18:34:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Kapfer X-Patchwork-Id: 1986 Return-Path: Received: from mail01.ipfire.org (mail01.i.ipfire.org [172.28.1.200]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail01.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web07.i.ipfire.org (Postfix) with ESMTPS id CE0A18AB84A for ; Tue, 4 Dec 2018 07:34:23 +0000 (GMT) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 98FF720888E7; Tue, 4 Dec 2018 07:34:22 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1543908863; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:list-id: list-unsubscribe:list-subscribe:list-post; bh=2OTkeNDpYjrft8DGUZyOWmA3DJZkNnUPq680ONLPGu4=; b=nzyRJHBlFPjtNZ9DuZBA/BisrPSU673S2cwqAmg20MUj3WQjhSsXprL5PCIMe7zJGAQ5yE IBiK6DOqQoBucDhv+CHAJPWjOosFAL1W5NYtx+X7/UFGWWsSMtuM8ppOl3JfE/RsQ+/hP/ lVnVBLu8yHyfM0j+0E21PHsp02WzxM0lz/asnmdLgGpQZBt4moI5TDI+9QS9zcVDQh5sPU fBzPPy/lL6v5pMgEu1AdwNubjdoE6hE+ofJZ4R+lv0EbCDp4LpRLgDAj9t1Vw1CL0zgiuc C7Gk5sjjxLHHKeXtmCItnktAbqYtk4zb4wku7Fhnhb97u5zveXhd8X/L6ifhcQ== Received: from ipfire-server.local (i59F4D43D.versanet.de [89.244.212.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 4A5A121AEFF8; Tue, 4 Dec 2018 07:34:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1543908857; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=2OTkeNDpYjrft8DGUZyOWmA3DJZkNnUPq680ONLPGu4=; b=PSfj7AGQnqrxpuE+2leVqvcC28yELtmh/W0AWq8/iIdfGTv1s++y3cBeLoAnxSuM9Oyg7G YR3UYNYoY2RYQ61f/DskzJyNHDSbuBGxPpzrqeWINEA4lxbU8dhdD2Zt3B7H35dqhnZrtc hFLrTtQRPAf8wtuNPjw601Kh/eLZZ6rqWunLOm2GWwtDsHGPy46zJFuAsuXyIsnAgQfupp lIttM7/AtYrFBfYDSBrfXe/97lv45AojQCOFDk+BTsCRHV2hr7xwAgqhWGPzc65xUy3WFG bHXHy8RlKLal83uso7FbuKdCsQmYcWy7ffwLBhQ2Gj9lt1ao1RHskjKFUq9jow== From: Erik Kapfer To: development@lists.ipfire.org Subject: [PATCH] OpenVPN: Calculate CIDR to DDN notation for RW Date: Tue, 4 Dec 2018 08:34:02 +0100 Message-Id: <20181204073402.27898-1-erik.kapfer@ipfire.org> X-Mailer: git-send-email 2.12.2 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=ummeegge smtp.mailfrom=erik.kapfer@ipfire.org X-Spamd-Result: default: False [-2.35 / 11.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-0.25)[-0.082,0]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8881, ipnet:89.244.208.0/20, country:DE]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-2.35 X-Rspamd-Server: mail01.i.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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.