Skip to content

Commit

Permalink
[fix] Fixed typo in fields of ZeroTier backend #342
Browse files Browse the repository at this point in the history
Fixes #342
  • Loading branch information
pandafy committed Feb 28, 2025
1 parent f569320 commit 6f05c29
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
29 changes: 14 additions & 15 deletions docs/source/backends/zerotier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ See an example of initialization and rendering below:
"remoteTraceLevel": 1,
"client_options": {
"allow_managed": True,
"allowed_global": False,
"allowed_default": False,
"allowed_dns": False,
"allow_global": False,
"allow_default": False,
"allow_dns": False,
},
}
]
Expand Down Expand Up @@ -276,18 +276,17 @@ key name type default description
``remoteTraceLevel`` integer level of network tracing
``client_options`` dict ``{}`` These options are only used for client configurations

=================== ======= ==========================================
key name type description
=================== ======= ==========================================
``allow_managed`` boolean allow ZeroTier to set IP addresses and
routes
``allowed_global`` boolean allow ZeroTier to set
global/public/not-private range IPs and
routes
``allowed_default`` boolean allow ZeroTier to set the default route on
the system
``allowed_dns`` boolean allow ZeroTier to set DNS servers
=================== ======= ==========================================
================= ======= =============================================
key name type description
================= ======= =============================================
``allow_managed`` boolean allow ZeroTier to set IP addresses and routes
``allow_global`` boolean allow ZeroTier to set
global/public/not-private range IPs and
routes
``allow_default`` boolean allow ZeroTier to set the default route on
the system
``allow_dns`` boolean allow ZeroTier to set DNS servers
================= ======= =============================================
===================== ======= =========== =======================================================================

Client specific settings
Expand Down
12 changes: 6 additions & 6 deletions netjsonconfig/backends/openwrt/converters/zerotier.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def __netjson_network(self, network):
network.pop(key)
network['ifname'] = self._get_ifname_from_id(network['id'])
# Handle boolean fields
if 'allowed_global' in network:
network['allowed_global'] = network['allowed_global'] == '1'
if 'allowed_default' in network:
network['allowed_default'] = network['allowed_default'] == '1'
if 'allowed_dns' in network:
network['allowed_dns'] = network['allowed_dns'] == '1'
if 'allow_global' in network:
network['allow_global'] = network['allow_global'] == '1'
if 'allow_default' in network:
network['allow_default'] = network['allow_default'] == '1'
if 'allow_dns' in network:
network['allow_dns'] = network['allow_dns'] == '1'
if 'allow_managed' in network:
network['allow_managed'] = network['allow_managed'] == '1'
return network
Expand Down
36 changes: 18 additions & 18 deletions tests/openwrt/test_zerotier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class TestZeroTier(unittest.TestCase, _TabsMixin):
"id": "9536600adf654321",
"ifname": "owzt654321",
"allow_managed": True,
"allowed_global": False,
"allowed_default": False,
"allowed_dns": False,
"allow_global": False,
"allow_default": False,
"allow_dns": False,
},
{
"id": "9536600adf654322",
"ifname": "owzt654322",
"allow_managed": True,
"allowed_global": False,
"allowed_default": False,
"allowed_dns": False,
"allow_global": False,
"allow_default": False,
"allow_dns": False,
},
],
},
Expand All @@ -46,17 +46,17 @@ class TestZeroTier(unittest.TestCase, _TabsMixin):
option local_conf_path '/etc/openwisp/zerotier/zerotier.conf'
config network 'owzt654321'
option allow_default '0'
option allow_dns '0'
option allow_global '0'
option allow_managed '1'
option allowed_default '0'
option allowed_dns '0'
option allowed_global '0'
option id '9536600adf654321'
config network 'owzt654322'
option allow_default '0'
option allow_dns '0'
option allow_global '0'
option allow_managed '1'
option allowed_default '0'
option allowed_dns '0'
option allowed_global '0'
option id '9536600adf654322'
# ---------- files ---------- #
Expand Down Expand Up @@ -132,10 +132,10 @@ def test_zt_parse_new(self):
config network
option id '9536600adf654322'
option allow_default '0'
option allow_dns '0'
option allow_global '0'
option allow_managed '1'
option allowed_default '0'
option allowed_dns '0'
option allowed_global '0'
"""
)
expected = {
Expand All @@ -148,9 +148,9 @@ def test_zt_parse_new(self):
"id": "9536600adf654322",
"ifname": "owzt654322",
"allow_managed": True,
"allowed_global": False,
"allowed_default": False,
"allowed_dns": False,
"allow_global": False,
"allow_default": False,
"allow_dns": False,
},
],
"name": "ow_zt",
Expand Down
6 changes: 3 additions & 3 deletions tests/zerotier/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class TestBackend(unittest.TestCase):
"remoteTraceLevel": 1,
"client_options": {
"allow_managed": True,
"allowed_global": False,
"allowed_default": False,
"allowed_dns": False,
"allow_global": False,
"allow_default": False,
"allow_dns": False,
},
}
]
Expand Down

0 comments on commit 6f05c29

Please sign in to comment.