Skip to content

System: Routing: Changed disable option to enable#10027

Merged
fichtner merged 11 commits intoopnsense:masterfrom
TomWalraven:route-disable-to-enable
Apr 13, 2026
Merged

System: Routing: Changed disable option to enable#10027
fichtner merged 11 commits intoopnsense:masterfrom
TomWalraven:route-disable-to-enable

Conversation

@TomWalraven
Copy link
Copy Markdown
Contributor

@TomWalraven TomWalraven commented Mar 24, 2026

Changed the disabled option to enabled in system routes configuration.

Closes: #8780

@fichtner fichtner self-assigned this Mar 24, 2026
Comment thread src/opnsense/mvc/app/models/OPNsense/Routes/Route.xml Outdated
@TomWalraven TomWalraven marked this pull request as draft March 24, 2026 09:39
@TomWalraven TomWalraven force-pushed the route-disable-to-enable branch from 35ea233 to bb11f1d Compare March 26, 2026 16:00
Comment thread src/opnsense/mvc/app/models/OPNsense/Routes/Migrations/M1_0_1.php Outdated
Comment thread src/etc/inc/system.inc Outdated
@TomWalraven TomWalraven marked this pull request as ready for review April 1, 2026 06:57
@TomWalraven TomWalraven force-pushed the route-disable-to-enable branch from 3502f90 to 988fc12 Compare April 3, 2026 11:38
Comment thread src/etc/inc/plugins.inc.d/pf.inc Outdated
Comment thread src/opnsense/mvc/app/models/OPNsense/Routes/Migrations/M1_0_1.php
Comment thread src/opnsense/mvc/app/models/OPNsense/Routes/Migrations/M1_0_1.php Outdated
@fichtner
Copy link
Copy Markdown
Member

fichtner commented Apr 7, 2026

I did a quick audit of where else this is used and cleaned this up faa7dab where necessary.. I think folding the compat into get_staticroutes() is a good way forward that minimizes impact :)

@TomWalraven TomWalraven force-pushed the route-disable-to-enable branch 2 times, most recently from 72574a1 to 3d4c41a Compare April 9, 2026 08:58
Comment thread src/etc/inc/util.inc Outdated
Copy link
Copy Markdown
Member

@fichtner fichtner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this turned out better than I could hope for. very nicely done 👍

Comment thread src/opnsense/mvc/app/models/OPNsense/Routes/Migrations/M1_0_1.php Outdated
Comment on lines +126 to +139
public function togglerouteAction($uuid, $enabled = null)
{
$result = array("result" => "failed");
if ($this->request->isPost() && $uuid != null) {
$node = $this->getModel()->getNodeByReference('route.' . $uuid);
if ($node != null) {
if ($disabled == '0' || $disabled == '1') {
$node->disabled = (string)$disabled;
} elseif ((string)$node->disabled == '1') {
$node->disabled = '0';
if ($enabled == '0' || $enabled == '1') {
$node->enabled = (string)$enabled;
} elseif ((string)$node->enabled == '1') {
$node->enabled = '0';
} else {
$node->disabled = '1';
$node->enabled = '1';
}
$result['result'] = (string)$node->disabled == '1' ? 'Disabled' : 'Enabled';
$result['result'] = (string)$node->enabled == '1' ? 'Enabled' : 'Disabled';
Copy link
Copy Markdown
Member

@swhite2 swhite2 Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can use toggleBase() now. In fact, this allows the front-end to use multi-select as well (batched toggle):

https://github.com/opnsense/core/blob/master/src/opnsense/mvc/app/views/OPNsense/Routes/index.volt#L39

({selection: true})

Make sure to set batchDelete: false as well, as the delrouteAction doesn't account for multiple UUIDs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 0f041ae. Thanks for the suggestion 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If toggleBase() is used, this comment can go as well.

@TomWalraven TomWalraven force-pushed the route-disable-to-enable branch from daedcf7 to 0f041ae Compare April 13, 2026 08:07
Copy link
Copy Markdown
Member

@swhite2 swhite2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff :)

@fichtner fichtner merged commit 3acfb5f into opnsense:master Apr 13, 2026
@fichtner
Copy link
Copy Markdown
Member

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

system: change "disable" routes configuration to a more intuitive "enable"

4 participants