-
Notifications
You must be signed in to change notification settings - Fork 759
net/zerotier: Configure ZeroTier network options #4746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,10 @@ public function setAction($uuid = null) | |
| $mdlZerotier->serializeToConfig(); | ||
| Config::getInstance()->save(); | ||
| $result["result"] = "saved"; | ||
| $this->setZerotierNetwork($network->networkId, 'allowManaged', $network->allowManaged); | ||
| $this->setZerotierNetwork($network->networkId, 'allowGlobal', $network->allowGlobal); | ||
| $this->setZerotierNetwork($network->networkId, 'allowDefault', $network->allowDefault); | ||
| $this->setZerotierNetwork($network->networkId, 'allowDNS', $network->allowDNS); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -192,8 +196,10 @@ public function toggleAction($uuid = null) | |
|
|
||
| private function toggleZerotierNetwork($networkId, $enabled) | ||
| { | ||
| $backend = new Backend(); | ||
| $backend->configdRun("template reload OPNsense/zerotier"); | ||
| $action = $enabled ? 'join' : 'leave'; | ||
| return trim((new Backend())->configdRun("zerotier $action $networkId")); | ||
| return trim($backend->configdRun("zerotier $action $networkId")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this already was an unsafe call, check out configdpRun() |
||
| } | ||
|
|
||
| private function listZerotierNetwork($networkId) | ||
|
|
@@ -207,4 +213,9 @@ private function listZerotierNetwork($networkId) | |
| } | ||
| return gettext("Unable to obtain Zerotier information for network") . " " . $networkId . "! " . gettext("Is the network enabled?"); | ||
| } | ||
|
|
||
| private function setZerotierNetwork($networkId, $setting, $value) | ||
| { | ||
| return trim((new Backend())->configdRun("zerotier set $networkId $setting $value")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also unsafe, check configdpRun() |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,22 @@ | |
| <default></default> | ||
| <Required>N</Required> | ||
| </description> | ||
| <allowManaged type="BooleanField"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since you add new required values with defaults the model version at the beginning of this file needs to be increased |
||
| <default>1</default> | ||
| <Required>Y</Required> | ||
| </allowManaged> | ||
| <allowGlobal type="BooleanField"> | ||
| <default>0</default> | ||
| <Required>Y</Required> | ||
| </allowGlobal> | ||
| <allowDefault type="BooleanField"> | ||
| <default>0</default> | ||
| <Required>Y</Required> | ||
| </allowDefault> | ||
| <allowDNS type="BooleanField"> | ||
| <default>0</default> | ||
| <Required>Y</Required> | ||
| </allowDNS> | ||
| </network> | ||
| </networks> | ||
| </items> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| zerotier:/etc/rc.conf.d/zerotier | ||
| local.conf:/var/db/zerotier-one/local.conf | ||
| networks-local.conf:/var/db/zerotier-one/networks.d/[OPNsense.zerotier.networks.network.%.networkId].local.conf | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note these files generated with dynamic names can not be deleted... |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| {% if helpers.exists('OPNsense.zerotier.networks') %} | ||
| {% for network in helpers.toList('OPNsense.zerotier.networks.network') %} | ||
| {% if TARGET_FILTERS['OPNsense.zerotier.networks.network.' ~ loop.index0] or TARGET_FILTERS['OPNsense.zerotier.networks.network'] %} | ||
| allowManaged={{ network.allowManaged }} | ||
| allowGlobal={{ network.allowGlobal }} | ||
| allowDefault={{ network.allowDefault }} | ||
| allowDNS={{ network.allowDNS }} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks rather odd, but the controller is also quite old
what is your goal here to directly apply this after config save?