mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-04 08:13:38 +00:00
Tests: - Functional tests work. - Initial setup works - Sometimes fails to write tunnel configuration (See #2127). - Favorites are created as listed in FAVORITES in resources.py - Tunnels are created: I2P HTTP Proxy, I2P HTTPS Proxy, Irc2P Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
27 lines
772 B
Python
27 lines
772 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Configure I2P."""
|
|
|
|
from typing import Optional
|
|
|
|
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: Optional[str],
|
|
icon: Optional[str]):
|
|
"""Add a favorite to router.config."""
|
|
editor = RouterEditor()
|
|
editor.read_conf().add_favorite(name, url, description, icon).write_conf()
|