From patchwork Tue Oct 27 22:21:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 10513 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4jDlMX3ZWNz3xZg for ; Tue, 27 Oct 2026 22:21:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (Client CN "mail02.haj.ipfire.org", Issuer "YE2" (not verified)) by mail01.ipfire.org (Postfix) with ESMTPS id 4jDlMW2zdGz7BZ for ; Tue, 27 Oct 2026 22:21:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [IPv6:::1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4jDlMV3jNwz36WT for ; Tue, 27 Oct 2026 22:21:26 +0000 (UTC) X-Original-To: development@lists.ipfire.org Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4jDlMH43xrz2yrG for ; Tue, 27 Oct 2026 22:21:15 +0000 (UTC) Received: from mout-b-106.mailbox.org (mout-b-106.mailbox.org [IPv6:2001:67c:2050:102:465::106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bit raw public key) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.mailbox.org", Issuer "Thawte TLS RSA CA G1" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4jDlMG4HYVz4jx for ; Tue, 27 Oct 2026 22:21:14 +0000 (UTC) Authentication-Results: mail01.ipfire.org; dkim=pass header.d=mandelbit.com header.s=MBO0001 header.b="A/BMNmCf"; spf=pass (mail01.ipfire.org: domain of antonio@mandelbit.com designates 2001:67c:2050:102:465::106 as permitted sender) smtp.mailfrom=antonio@mandelbit.com; dmarc=none ARC-Seal: i=1; a=rsa-sha256; d=lists.ipfire.org; s=202003rsa; cv=none; t=1793139674; b=FahEQDa0yu0dT7SnGy8hhBloZwqOgBaTY4mVs2tvAT6RntN2wJkJVxB/OI2q6igt4q/Ki0 RyqmYETNzYcjiodqvkvhDGNFqVwWLHpHwvrA0hzZsDNr/imvDckyP++ohDCXqSJEjRLzpG bJ7dDtHdNRLlSRrlXzqlOIhGJK4m3a71MnzuKDq+oZW8IIBmIqDlOmTUXGe4GJ83ysyTXg 7hKe7aJ8FpwW8kCy/D23aFtmhsY2slVox9ImBAzXwaTDMUb7NBz/6yYKkjPWZ5u/VWxQGm suSc/r3vonS5icO8OxLdyXPfXUQW32embZXofF1jQxbbfDgThy7qFBAGsBn1JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1793139674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OuChQEeWelrnBoJu0msaDJJA5I0W+Bl5pzMpYJJ8+9Q=; b=ZXoRyazuEEHYnkj+lQ5P3vPzI3OiWI0XeU0CBi+co5bQ2u/2uTCYmAjD5mb7q2OHLnoq6N WqL5mEP7CCQFQfaJXYCVzVMGjwYzPjgTReG19+hb/1XzSoVNSfZCqM3dA4P+yJnhBYZqGN HfF2zpURIPAQ+qJKX+EpbanJQZpPTSjiFhorgaA8ecuY0qH8uEG+rkbyB3TtsAY6+hJij2 wBlt0zYiMGTd5O0npj4EiIWsbHdUcRg517tcvwW7SAE6iiSjYgC0qhVCOJr/MQqiPi5e+u HAHocCQfCqndmYrraNlzpjbrh0lTcBNOD9OjUMcqaNp+X5QiFuMrdvU5auNyRg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=mandelbit.com header.s=MBO0001 header.b="A/BMNmCf"; spf=pass (mail01.ipfire.org: domain of antonio@mandelbit.com designates 2001:67c:2050:102:465::106 as permitted sender) smtp.mailfrom=antonio@mandelbit.com; dmarc=none Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-106.mailbox.org (Postfix) with ESMTPS id 4jDlMF5KvMzNlhJ; Tue, 27 Oct 2026 23:21:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1793139673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OuChQEeWelrnBoJu0msaDJJA5I0W+Bl5pzMpYJJ8+9Q=; b=A/BMNmCfOrLIqF6W7BAwYQydn0EwV8k28/WrqBujcho9M8B/05LnkHGhEGwk1ayPg5tPSR sBWqzHHv5J8Z90hqNWZLocMqXpGL3hLnJ6XqOciYEyL15JSVG/yky2hdCAQsZvZfRzBW32 UbWkY1WjUXUdkVz6jENvc3AAcI3OmhuGHr24nkxeedG7kpBdvzlk5jQpzLYqNubRqsr4EW 90Ru2QX1RwnAwx8aVKMZrQNRLMERKWP/m0Me8MFsfdDKCsA7yJGyYHKHU6ROHKw7ARHUL9 YugEHNueTlDjuFDwUnS3TZVGStZLCRiecCPfbR/U7VdZjmgCWGRIZvtmDiVwAg== From: Antonio Quartulli To: development@lists.ipfire.org Cc: Antonio Quartulli Subject: [PATCH 2/3] ovpnmain.cgi/index.cgi: Use OpenVPN::n2n_status() Date: Tue, 27 Oct 2026 23:21:09 +0100 Message-ID: <20261027222110.2642078-3-antonio@mandelbit.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261027222110.2642078-1-antonio@mandelbit.com> References: <20261027222110.2642078-1-antonio@mandelbit.com> Precedence: list List-Id: List-Subscribe: , List-Unsubscribe: , List-Post: List-Help: Sender: Mail-Followup-To: MIME-Version: 1.0 X-Rspamd-Action: no action X-Spamd-Result: default: False [-2.20 / 11.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:67c:2050::/48:c]; R_DKIM_ALLOW(-0.10)[mandelbit.com:s=MBO0001]; RCVD_IN_DNSWL_LOW(-0.10)[2001:67c:2050:b231:465::1:received]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.10)[mxext2.mailbox.org]; R_DKIM_ALIGNED(-0.10)[strict]; ASN(0.00)[asn:199118, ipnet:2001:67c:2050::/48, country:DE]; RCVD_COUNT_ONE(0.00)[1]; TO_DN_SOME(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; IP_REPUTATION_HAM(0.00)[asn: 199118(-0.31), country: DE(-0.01), ip: 2001:67c:2050:102::(0.00)]; DMARC_NA(0.00)[mandelbit.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_REPUTATION(0.00)[0]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[mandelbit.com:+] X-Rspamd-Server: mail01.haj.ipfire.org X-Rspamd-Queue-Id: 4jDlMG4HYVz4jx Both pages now use the same check, so a working N2N tunnel is no longer shown as DISCONNECTED after an incomplete session attempt. Fixes: #13897 Signed-off-by: Antonio Quartulli --- html/cgi-bin/index.cgi | 12 ++------ html/cgi-bin/ovpnmain.cgi | 58 ++------------------------------------- 2 files changed, 5 insertions(+), 65 deletions(-) diff --git a/html/cgi-bin/index.cgi b/html/cgi-bin/index.cgi index 0f51ba9ff..b5f23a59a 100644 --- a/html/cgi-bin/index.cgi +++ b/html/cgi-bin/index.cgi @@ -20,7 +20,6 @@ ############################################################################### use strict; -use Net::Telnet; use Sort::Naturally; # enable only the following on debugging purpose @@ -31,6 +30,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "${General::swroot}/wireguard-functions.pl"; +require "${General::swroot}/ovpn-functions.pl"; require "/opt/pakfire/lib/functions.pl"; my %cgiparams=(); @@ -504,17 +504,11 @@ END $count++; my $tport = $ovpnconfig{$dkey}[22]; next if ($tport eq ''); - my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); - $tnet->open('127.0.0.1'); - my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/'); - my @tustate = split(/\,/, $output[1]); - my $display; + my $display = _('DISCONNECTED'); my $display_colour = $Header::colourred; - if ( $tustate[1] eq 'CONNECTED' || ($tustate[1] eq 'WAIT')) { + if (&OpenVPN::n2n_status($tport) eq "CONNECTED") { $display_colour = $Header::colourgreen; $display = _('CONNECTED'); - } else { - $display = $tustate[1]; } if ($count %2){ $col = $color{'color22'}; diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 35561f4e7..d28f895cd 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -31,7 +31,6 @@ use MIME::Base32; use MIME::Base64; use Net::DNS; use Net::Ping; -use Net::Telnet; use Sort::Naturally; use URI::Encode qw(uri_encode uri_decode);; @@ -39,6 +38,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/header.pl"; require "${General::swroot}/countries.pl"; require "${General::swroot}/location-functions.pl"; +require "${General::swroot}/ovpn-functions.pl"; # enable only the following on debugging purpose #use warnings; @@ -1024,60 +1024,6 @@ sub writecollectdconf { &General::system("/usr/local/bin/collectdctrl", "restart"); } -sub openvpn_status($) { - my $port = shift; - - # Create a new Telnet session - my $telnet = new Net::Telnet( - Port => $port, - Timeout => 1, - Errmode => "return", - ); - - # Connect - $telnet->open("127.0.0.1"); - - # Send a command - my @output = $telnet->cmd( - String => "state", - Prompt => "/(END.*\n|ERROR:.*\n)/" - ); - - my ($time, $status) = split(/\,/, $output[1]); - - ### - #CONNECTING -- OpenVPN's initial state. - #WAIT -- (Client only) Waiting for initial response from server. - #AUTH -- (Client only) Authenticating with server. - #GET_CONFIG -- (Client only) Downloading configuration options from server. - #ASSIGN_IP -- Assigning IP address to virtual network interface. - #ADD_ROUTES -- Adding routes to system. - #CONNECTED -- Initialization Sequence Completed. - #RECONNECTING -- A restart has occurred. - #EXITING -- A graceful exit is in progress. - #### - - if ($status eq "CONNECTING") { - return "DISCONNECTED"; - } elsif ($status eq "WAIT") { - return "DISCONNECTED"; - } elsif ($status eq "AUTH") { - return "DISCONNECTED"; - } elsif ($status eq "GET_CONFIG") { - return "DISCONNECTED"; - } elsif ($status eq "ASSIGN_IP") { - return "DISCONNECTED"; - } elsif ($status eq "ADD_ROUTES") { - return "DISCONNECTED"; - } elsif ($status eq "RECONNECTING") { - return "CONNECTED"; - } elsif ($status eq "EXITING") { - return "DISCONNECTED"; - } - - return $status; -} - # Hook to regenerate the configuration files if ($ENV{"REMOTE_ADDR"} eq "") { &writeserverconf(); @@ -5309,7 +5255,7 @@ END my $port = $confighash{$key}[22]; if ($port ne "") { - $connstatus = &openvpn_status($confighash{$key}[22]); + $connstatus = &OpenVPN::n2n_status($port); } }