mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
Tests: - mypy does not show any errors. - Installing ejabberd app works. Privileged actions run fine. - Unit tests work. - No additional testing was done as type annotations don't have any effect at runtime. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
25 lines
737 B
Python
25 lines
737 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Configure I2P."""
|
|
|
|
from plinth.actions import privileged
|
|
from plinth.modules.i2p.helpers import RouterEditor, TunnelEditor
|
|
|
|
|
|
@privileged
|
|
def set_tunnel_property(name: str, property_: str, value: str):
|
|
"""Modify the configuration file for a certain tunnel."""
|
|
editor = TunnelEditor()
|
|
editor \
|
|
.read_conf() \
|
|
.set_tunnel_idx(name) \
|
|
.set_tunnel_prop(property_, value) \
|
|
.write_conf()
|
|
|
|
|
|
@privileged
|
|
def add_favorite(name: str, url: str, description: str | None,
|
|
icon: str | None):
|
|
"""Add a favorite to router.config."""
|
|
editor = RouterEditor()
|
|
editor.read_conf().add_favorite(name, url, description, icon).write_conf()
|