mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-22 11:59:33 +00:00
i2p: Open HTTP(S) and IRC ports on all interfaces on install
I2P has to be restarted in order for the changes to take effect. Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
eb28f47053
commit
5c26c28f96
25
actions/i2p
25
actions/i2p
@ -23,6 +23,7 @@ import argparse
|
||||
import os
|
||||
|
||||
from plinth import action_utils, cfg
|
||||
from plinth.modules.i2p.helpers import TunnelEditor
|
||||
|
||||
cfg.read()
|
||||
module_config_path = os.path.join(cfg.config_dir, 'modules-enabled')
|
||||
@ -43,6 +44,12 @@ def parse_arguments():
|
||||
subparser.add_argument('--name', help='Name of the entry', required=True)
|
||||
subparser.add_argument('--url', help='URL of the entry', required=True)
|
||||
|
||||
subparser = subparsers.add_parser(
|
||||
'set-tunnel-property', help='Modify configuration of a tunnel')
|
||||
subparser.add_argument('--name', help='Name of the tunnel', required=True)
|
||||
subparser.add_argument('--property', help='Property to modify', required=True)
|
||||
subparser.add_argument('--value', help='Value to assign', required=True)
|
||||
|
||||
subparsers.required = True
|
||||
return parser.parse_args()
|
||||
|
||||
@ -59,6 +66,24 @@ def subcommand_disable(_):
|
||||
action_utils.webserver_disable('i2p-freedombox')
|
||||
|
||||
|
||||
def subcommand_set_tunnel_property(arguments):
|
||||
"""
|
||||
Modifies the configuration for a certain tunnel
|
||||
"""
|
||||
|
||||
editor = TunnelEditor()
|
||||
editor \
|
||||
.read_conf() \
|
||||
.set_tunnel_idx(arguments.name) \
|
||||
.set_tunnel_prop(arguments.property, arguments.value) \
|
||||
.write_conf()
|
||||
print('Updated "{property}" of {filename} to {value}'.format(
|
||||
property=editor.calc_prop_path(arguments.property),
|
||||
filename=editor.conf_filename,
|
||||
value=arguments.value
|
||||
))
|
||||
|
||||
|
||||
def subcommand_add_favorite(arguments):
|
||||
"""
|
||||
Adds a favorite to the router.config
|
||||
|
||||
@ -24,7 +24,6 @@ from plinth import action_utils, actions, frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.menu import main_menu
|
||||
from plinth.modules.users import register_group
|
||||
|
||||
from .manifest import backup, clients
|
||||
|
||||
version = 1
|
||||
@ -65,6 +64,12 @@ additional_favorites = [
|
||||
('YaCy Seeker', 'http://seeker.i2p'),
|
||||
]
|
||||
|
||||
tunnels_to_manage = [
|
||||
'I2P HTTP Proxy',
|
||||
'I2P HTTPS Proxy',
|
||||
'Irc2P'
|
||||
]
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the module."""
|
||||
@ -98,6 +103,15 @@ def setup(helper, old_version=None):
|
||||
'--url',
|
||||
fav_url,
|
||||
])
|
||||
|
||||
# Tunnels to all interfaces
|
||||
for tunnel in tunnels_to_manage:
|
||||
helper.call('post', actions.superuser_run, 'i2p', [
|
||||
'set-tunnel-property',
|
||||
'--name', tunnel,
|
||||
'--property', 'interface',
|
||||
'--value', '0.0.0.0'
|
||||
])
|
||||
helper.call('post', enable)
|
||||
global service
|
||||
if service is None:
|
||||
|
||||
@ -71,7 +71,7 @@ class TunnelEditor(object):
|
||||
if match and self.aug.get(prop) == name:
|
||||
self.idx = int(match.group(1))
|
||||
return self
|
||||
raise ValueError('No tunnel with that name')
|
||||
raise ValueError('No tunnel called {}'.format(name))
|
||||
|
||||
def calc_prop_path(self, tunnel_prop):
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user