paradrop.backend.pdconfd.config package¶
Submodules¶
paradrop.backend.pdconfd.config.base module¶
-
class
ConfigObject
[source]¶ Bases:
object
-
classmethod
build
(manager, source, name, options, comment)[source]¶ Build a config object instance from the UCI section.
Arguments: source – file containing this configuration section name – name of the configuration section
If None, a unique name will be generated.options – dictionary of options loaded from the section comment – comment string or None
-
lookup
(allConfigs, sectionType, sectionName, addDependent=True)[source]¶ Look up a section by type and name.
If addDependent is True (default), the current object will be added as a dependent of the found section.
Will raise an exception if the section is not found.
-
nextId
= 0¶
-
options
= []¶
-
typename
= None¶
-
classmethod
paradrop.backend.pdconfd.config.command module¶
paradrop.backend.pdconfd.config.dhcp module¶
-
class
ConfigDhcp
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': True, 'type': <type 'str'>, 'name': 'interface'}, {'default': '12h', 'required': True, 'type': <type 'str'>, 'name': 'leasetime'}, {'default': 150, 'required': True, 'type': <type 'int'>, 'name': 'limit'}, {'default': 100, 'required': True, 'type': <type 'int'>, 'name': 'start'}, {'default': '', 'required': False, 'type': <type 'list'>, 'name': 'dhcp_option'}]¶
-
typename
= 'dhcp'¶
-
-
class
ConfigDnsmasq
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': False, 'type': <type 'list'>, 'name': 'interface'}, {'default': False, 'required': False, 'type': <type 'bool'>, 'name': 'noresolv'}, {'default': None, 'required': False, 'type': <type 'list'>, 'name': 'server'}]¶
-
typename
= 'dnsmasq'¶
-
paradrop.backend.pdconfd.config.firewall module¶
-
class
ConfigRedirect
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': False, 'type': <type 'str'>, 'name': 'src'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'src_ip'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'src_dip'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'src_port'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'src_dport'}, {'default': 'tcpudp', 'required': True, 'type': <type 'str'>, 'name': 'proto'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'dest'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'dest_ip'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'dest_port'}, {'default': 'DNAT', 'required': False, 'type': <type 'str'>, 'name': 'target'}]¶
-
typename
= 'redirect'¶
-
-
class
ConfigZone
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': True, 'type': <type 'str'>, 'name': 'name'}, {'default': None, 'required': False, 'type': <type 'list'>, 'name': 'network'}, {'default': False, 'required': False, 'type': <type 'bool'>, 'name': 'masq'}, {'default': 'DROP', 'required': False, 'type': <type 'str'>, 'name': 'input'}, {'default': 'DROP', 'required': False, 'type': <type 'str'>, 'name': 'forward'}, {'default': 'DROP', 'required': False, 'type': <type 'str'>, 'name': 'output'}]¶
-
typename
= 'zone'¶
-
paradrop.backend.pdconfd.config.manager module¶
-
class
ConfigManager
(writeDir)[source]¶ Bases:
object
-
changingSet
(files)[source]¶ Return the sections from the current configuration that may have changed.
This checks which sections from the current configuration came from files in the given file list. These are sections that may be changed or removed when we reload the files.
-
findMatchingConfig
(config, byName=False)[source]¶ Check the current config for an identical section.
Returns the matching object or None.
-
loadConfig
(search=None, execute=True)[source]¶ Load configuration files and apply changes to the system.
We process the configuration files in sections. Each section corresponds to an interface, firewall rule, DHCP server instance, etc. Each time we reload configuration files after the initial time, we check for changes against the current configuration. Here is the decision tree for handling differences in the newly loaded configuration vs. the existing configuration:
- Section exists in current config (by type and name)?
- No -> Add section, apply changes, and stop.
- Yes -> Continue.
Section is identical to the one in the current config (by option values)?
- No -> Revert current section, mark any affected dependents,
add new section, apply changes, and stop.
Yes -> Continue.
- Section has not changed but one of its dependencies has?
No -> Stop.
- Yes -> Revert current section, mark any affected dependents,
add new section, apply changes, and stop.
-
readConfig
(files)[source]¶ Load configuration files and return configuration objects.
This method only loads the configuration files without making any changes to the system and returns configuration objects as a generator.
-
statusString
()[source]¶ Return a JSON string representing status of the system.
The format will be a list of dictionaries. Each dictionary corresponds to a configuration block and contains at the following fields.
type: interface, wifi-device, etc. name: name of the section (may be autogenerated for some configs) comment: comment from the configuration file or None success: True if all setup commands succeeded
-
-
findConfigFiles
(search=None)[source]¶ Look for and return a list of configuration files.
The behavior depends on whether the search argument is a file, a directory, or None.
If search is None, return a list of files in the system config directory. If search is a file name (not a path), look for it in the working directory first, and the system directory second. If search is a full path to a file, and it exists, then return that file. If search is a directory, return the files in that directory.
paradrop.backend.pdconfd.config.network module¶
-
class
ConfigInterface
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': True, 'type': <type 'str'>, 'name': 'proto'}, {'default': None, 'required': True, 'type': <type 'str'>, 'name': 'ifname'}, {'default': True, 'required': False, 'type': <type 'bool'>, 'name': 'enabled'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'ipaddr'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'netmask'}]¶
-
typename
= 'interface'¶
-
paradrop.backend.pdconfd.config.wireless module¶
-
class
ConfigWifiDevice
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': True, 'type': <type 'str'>, 'name': 'type'}, {'default': 1, 'required': True, 'type': <type 'int'>, 'name': 'channel'}]¶
-
typename
= 'wifi-device'¶
-
-
class
ConfigWifiIface
[source]¶ Bases:
paradrop.backend.pdconfd.config.base.ConfigObject
-
options
= [{'default': None, 'required': True, 'type': <type 'str'>, 'name': 'device'}, {'default': 'ap', 'required': True, 'type': <type 'str'>, 'name': 'mode'}, {'default': 'Paradrop', 'required': True, 'type': <type 'str'>, 'name': 'ssid'}, {'default': 'lan', 'required': True, 'type': <type 'str'>, 'name': 'network'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'encryption'}, {'default': None, 'required': False, 'type': <type 'str'>, 'name': 'key'}]¶
-
typename
= 'wifi-iface'¶
-