net/cloudflared: replace sysctl JS warning with AbstractStatus banner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Richard Aspden 2026-05-12 18:12:02 +01:00
parent 3a6cb1c622
commit 4a94664279
3 changed files with 56 additions and 51 deletions

View file

@ -34,18 +34,4 @@ class SettingsController extends ApiMutableModelControllerBase
{
protected static $internalModelClass = '\OPNsense\Cloudflared\Cloudflared';
protected static $internalModelName = 'cloudflared';
public function sysctlCheckAction()
{
$checks = [
'kern.ipc.maxsockbuf' => 16777216,
'net.inet.udp.recvspace' => 8388608,
];
$result = [];
foreach ($checks as $key => $minimum) {
$value = intval(trim(shell_exec('sysctl -n ' . escapeshellarg($key) . ' 2>/dev/null')));
$result[$key] = ['value' => $value, 'minimum' => $minimum, 'ok' => $value >= $minimum];
}
return $result;
}
}

View file

@ -0,0 +1,56 @@
<?php
/*
* Copyright (C) 2026 Richard Aspden <rick+github@insanityinside.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\System\Status;
use OPNsense\System\AbstractStatus;
use OPNsense\System\SystemStatusCode;
class CloudflaredOverrideStatus extends AbstractStatus
{
public function __construct()
{
$this->internalPriority = 2;
$this->internalPersistent = true;
$this->internalIsBanner = true;
$this->internalTitle = gettext('Cloudflare Tunnel');
$this->internalScope = [
'/ui/cloudflared/'
];
}
public function collectStatus()
{
$this->internalMessage = gettext(
'Cloudflare Tunnel traffic bypasses OPNsense firewall rules; access control must be enforced in ' .
'Cloudflare Access. For optimal QUIC performance, set the recommended kernel tunables. ' .
'See the plugin documentation for details.'
);
$this->internalStatus = SystemStatusCode::NOTICE;
}
}

View file

@ -26,37 +26,9 @@
<script>
$(document).ready(function() {
function updateSysctlWarning() {
var protocol = $("#cloudflared\\.general\\.protocol").val();
if (protocol !== 'auto' && protocol !== 'quic') {
$("#sysctl_warning").hide();
return;
}
ajaxCall("/api/cloudflared/settings/sysctlCheck", {}, function(data) {
var issues = [];
$.each({'kern.ipc.maxsockbuf': 16777216, 'net.inet.udp.recvspace': 8388608}, function(key, min) {
if (data[key] && !data[key].ok) {
issues.push(key + " {{ lang._('(current:') }} " + data[key].value +
"{{ lang._(', recommended: ≥') }} " + min + ")");
}
});
if (issues.length > 0) {
$("#sysctl_issues").html(issues.join("<br>"));
$("#sysctl_warning").show();
} else {
$("#sysctl_warning").hide();
}
});
}
mapDataToFormUI({'frm_GeneralSettings': "/api/cloudflared/settings/get"}).done(function() {
$('.selectpicker').selectpicker('refresh');
updateServiceControlUI('cloudflared');
updateSysctlWarning();
});
$("#cloudflared\\.general\\.protocol").on('change', function() {
updateSysctlWarning();
});
$("#reconfigureAct").SimpleActionButton({
@ -71,15 +43,6 @@ $(document).ready(function() {
<div class="content-box">
{{ partial('layout_partials/base_form', ['fields': general, 'id': 'frm_GeneralSettings']) }}
<div id="sysctl_warning" class="alert alert-warning" role="alert" style="margin: 10px; display: none;">
{{ lang._("QUIC performance: the following UDP buffer sysctl(s) are below the recommended values. Set them under") }}
<a href="/ui/core/tunables">{{ lang._("System > Settings > Tuneables") }}</a>
{{ lang._("for optimal tunnel throughput.") }}
<br><span id="sysctl_issues"></span>
</div>
<div class="alert alert-warning" role="alert" style="margin: 10px;">
{{ lang._("Traffic received via the Cloudflare Tunnel bypasses OPNsense firewall rules. Access control for tunnelled services must be enforced within Cloudflare Access. Backend services must also be reachable from the router's own IP address, as cloudflared forwards connections from the router itself.") }}
</div>
</div>
{{ partial('layout_partials/base_apply_button', {'data_endpoint': '/api/cloudflared/service/reconfigure', 'data_service_widget': 'cloudflared'}) }}