Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added support for ZeroTier to the OpenWRT backend #207
The schema is taken from OpenAPI specification: https://docs.zerotier.com/service/v1/ (self-hosted controllers) https://docs.zerotier.com/openapi/centralv1.json (central controllers) The Zerotier network configuration keys taken from: https://github.com/zerotier/ZeroTierOne/blob/dev/node/NetworkConfig.hpp Closes #208 Co-authored-by: Federico Capoano <f.capoano@openwisp.io>
- Loading branch information
1 parent
06234ef
commit 2bae0da
Showing
12 changed files
with
570 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from ...zerotier.converters import ZeroTier as BaseZeroTier | ||
from ..schema import schema | ||
from .base import OpenWrtConverter | ||
|
||
|
||
class ZeroTier(OpenWrtConverter, BaseZeroTier): | ||
_uci_types = ['zerotier'] | ||
_schema = schema['properties']['zerotier']['items'] | ||
|
||
def __intermediate_vpn(self, vpn): | ||
vpn.update( | ||
{ | ||
'.name': self._get_uci_name(vpn.pop('name')), | ||
'.type': 'zerotier', | ||
'join': vpn.pop('id'), | ||
'enabled': not vpn.pop('disabled', False), | ||
} | ||
) | ||
return super().__intermediate_vpn(vpn, remove=['']) | ||
|
||
def __netjson_vpn(self, vpn): | ||
vpn['id'] = vpn.pop('join') | ||
vpn['name'] = vpn.pop('.name').replace('_', '-') | ||
# 'disabled' defaults to False in OpenWRT | ||
vpn['disabled'] = vpn.pop('enabled', '0') == '0' | ||
del vpn['.type'] | ||
return super().__netjson_vpn(vpn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.