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:
LoveIsGrief 2019-04-08 20:13:16 +02:00 committed by Sunil Mohan Adapa
parent eb28f47053
commit 5c26c28f96
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 41 additions and 2 deletions

View File

@ -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

View File

@ -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:

View File

@ -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):
"""