package documentation

Library that handles the DPI rules.

From __init__.py:

Function add_exemption Store a new global exemption
Function add_rule Store a new rule
Function delete_exemption Delete a global exemption
Function delete_rule Delete a rule
Function edit_exemption Edit a global exemption
Function edit_rule Edit a rule
Function list_applications List applications available for filtering.
Function list_devices List device-interface available for filtering.
Function list_exemptions Index all global exemptions
Function list_popular List popular applications available for filtering.
Function list_rules Index all rules
Function __load_application_categories Reads the application categories from the netify-categories.json file.
Function __load_applications Reads the applications from the netify-apps.conf file.
Function __load_blocklist Format the applications and protocols into a list of dicts.
Function __load_protocol_categories Reads the protocol categories from the netify-categories.json file.
Function __load_protocols Reads the protocols from the netifyd --dump-protos command.
Function __save_exemption_data Undocumented
Function __save_rule_data Undocumented
Function __toggle_engine Undocumented
def add_exemption(e_uci: EUci, criteria: str, description: str, enabled: bool): (source)

Store a new global exemption

Args:
  • e_uci: euci instance
  • criteria: exemption criteria, usually it's an IP address
  • description: description of the rule
  • enabled: enable the exemption
Returns:
config name of the exemption created
def add_rule(e_uci: EUci, enabled: bool, device: str, action: str, applications: list[str], protocols: list[str]) -> str: (source)

Store a new rule

Args:
  • e_uci: euci instance
  • description: description of the rule
  • enabled: enable the rule
  • action: apply specific action to rule, can be 'block', 'bulk', 'best_effort', 'video' or 'voice'
  • device: device to listen and apply the rule on
  • applications: list of applications to block
  • protocols: list of protocols to block
Returns:
config name of the rule created
def delete_exemption(e_uci: EUci, config_name: str): (source)

Delete a global exemption

Args:
  • e_uci: euci instance
  • config_name: config name of the rule to delete
def delete_rule(e_uci: EUci, config_name: str): (source)

Delete a rule

Args:
  • e_uci: euci instance
  • config_name: config name of the rule to delete
def edit_exemption(e_uci: EUci, config_name: str, criteria: str, description: str, enabled: bool): (source)

Edit a global exemption

Args:
  • e_uci: euci instance
  • config_name: rule to change
  • criteria: exemption criteria, usually it's an IP address
  • description: description of the rule
  • enabled: enable the exemption
Raises
  • ValidationError: if the config name is invalid
def edit_rule(e_uci: EUci, config_name: str, enabled: bool, device: str, action: str, applications: list[str], protocols: list[str]): (source)

Edit a rule

Args:
  • e_uci: euci instance
  • config_name: rule to change
  • enabled: enable the rule
  • device: device to listen and apply the rule on
  • action: apply specific action to rule, can be 'block', 'bulk', 'best_effort', 'video' or 'voice'
  • applications: array of applications to block
  • protocols: array of protocols to block
Raises
  • ValidationError: if the config name is invalid
def list_applications(search: str = None, limit: int = None, page: int = 1) -> dict: (source)

List applications available for filtering.

Args:
  • search: search string
  • limit: limit the number of results
  • page: page number
Returns:
list of dicts, each dict contains the property "code" and "name"
def list_devices(e_uci: EUci): (source)

List device-interface available for filtering.

Returns:
list of dicts, each dict contains the property "interface" and "device"
def list_exemptions(e_uci: EUci) -> list[dict[str]]: (source)

Index all global exemptions

Args:
  • e_uci: euci instance
Returns:
list of dicts, each dict contains the property "config-name", "description", "enabled", "criteria"
def list_popular(e_uci: EUci, limit: int = None, page: int = 1) -> dict: (source)

List popular applications available for filtering.

Args:
  • limit: limit the number of results
  • page: page number
Returns:
list of dicts, each dict contains the property "id", "name", "type" and "category"
def list_rules(e_uci: EUci) -> list[dict[str]]: (source)

Index all rules

Args:
  • e_uci: euci instance
Returns:
list of dicts, each dict contains the property "config-name", "description", "enabled", "interface" and "blocks"
def __load_application_categories() -> dict[int, dict[str]]: (source)

Reads the application categories from the netify-categories.json file.

Returns:
dict of application categories, each dict contains the property "id" and "name"
def __load_applications() -> dict[int, str]: (source)

Reads the applications from the netify-apps.conf file.

Returns:
dict of applications, each dict contains the property "id" and "name"
def __load_blocklist() -> list[dict[str]]: (source)

Format the applications and protocols into a list of dicts.

Returns:
list of dicts, each dict contains the property "id", "name", "type" and "category"
def __load_protocol_categories() -> dict[int, dict[str]]: (source)

Reads the protocol categories from the netify-categories.json file.

Returns:
dict of protocol categories, each dict contains the property "id" and "name"
def __load_protocols() -> dict[int, str]: (source)

Reads the protocols from the netifyd --dump-protos command.

Returns:
dict of protocols, each dict contains the property "id" and "name"
def __save_exemption_data(e_uci: EUci, config_name: str, criteria: str, description: str, enabled: bool): (source)

Undocumented

def __save_rule_data(e_uci: EUci, config_name: str, enabled: bool, device: str, action: str, applications: list[str], protocols: list[str]): (source)

Undocumented

def __toggle_engine(e_uci: EUci): (source)

Undocumented