mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- Handle groups needed by an app.
- Handle reserved usernames for an app.
- Updated documentation
- Updated unit tests
Tests performed:
- Reserved usernames: ez-ipupd, ejabberd, Debian-minetest, mldonkey,
monkeysphere, mumble-server, privoxy, quasselcore, radicale, debian-tor,
debian-transmission
- Reserved usernames checks should work in the following forms:
- Create user
- Update user
- First boot user creation
- Full list of available groups should appear in following cases:
- Create user form
- Update user form
- Full list of groups should get created in Django DB during:
- Update user form display
- First boot form save
- When updating the last admin user, the 'admin' group choice is checked
and disabled.
- Following groups show up (sorted by group name):
- bit-torrent: Download files using BitTorrent applications
- git-access: Read-write access to Git repositories
- i2p: Manage I2P application
- wiki: View and edit wiki applications
- minidlna: Media streaming server
- ed2k: Download files using eDonkey applications
- freedombox-share: Access to the private shares
- web-search: Search the web
- syncthing: Administer Syncthing application
- feed-reader: Read and subscribe to news feeds
- admin: Access to all services and system settings
- Directory validation form checks for write permissions for following apps:
- deluge with debian-deluged user
- transmission with debian-transmission user
- Sharing app should show all the groups in add/edit share forms
- The following apps should get added to share group during setup:
debian-transmission
debian-deluged
- Unit tests pass
- Functional tests for users and groups pass
- Test that an app (example syncthing) provides the necessary
permissions to users in that group (but not in admin group).
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Fix i18n of group descriptions]
[sunil: Update developer documentation]
[sunil: Separate out cosmetic changes]
[sunil: Fix component ID for mumble]
[sunil: sharing: Remove unneeded dependency on users app]
[sunil: Implement better API for getting groups in component]
[sunil: Fix incorrect regression change ttrss app]
[sunil: Make iterating over gourps more readable]
[sunil: Improve tests, drop single use fixtures]
[sunil: Simplify test_view.py fixture]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Tested-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
145 lines
4.6 KiB
Python
145 lines
4.6 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
FreedomBox app to configure I2P.
|
|
"""
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from plinth import actions
|
|
from plinth import app as app_module
|
|
from plinth import frontpage, menu
|
|
from plinth.daemon import Daemon
|
|
from plinth.modules.apache.components import Webserver
|
|
from plinth.modules.firewall.components import Firewall
|
|
from plinth.modules.i2p.resources import FAVORITES
|
|
from plinth.modules.users.components import UsersAndGroups
|
|
|
|
from .manifest import backup, clients # noqa, pylint: disable=unused-import
|
|
|
|
version = 1
|
|
|
|
service_name = 'i2p'
|
|
|
|
managed_services = [service_name]
|
|
|
|
managed_packages = ['i2p']
|
|
|
|
_description = [
|
|
_('The Invisible Internet Project is an anonymous network layer intended '
|
|
'to protect communication from censorship and surveillance. I2P '
|
|
'provides anonymity by sending encrypted traffic through a '
|
|
'volunteer-run network distributed around the world.'),
|
|
_('Find more information about I2P on their project '
|
|
'<a href="https://geti2p.net" target="_blank">homepage</a>.'),
|
|
_('The first visit to the provided web interface will initiate the '
|
|
'configuration process.')
|
|
]
|
|
|
|
port_forwarding_info = [
|
|
('TCP', 4444),
|
|
('TCP', 4445),
|
|
('TCP', 6668),
|
|
]
|
|
|
|
tunnels_to_manage = {
|
|
'I2P HTTP Proxy': 'i2p-http-proxy-freedombox',
|
|
'I2P HTTPS Proxy': 'i2p-https-proxy-freedombox',
|
|
'Irc2P': 'i2p-irc-freedombox'
|
|
}
|
|
|
|
app = None
|
|
|
|
|
|
class I2PApp(app_module.App):
|
|
"""FreedomBox app for I2P."""
|
|
|
|
app_id = 'i2p'
|
|
|
|
def __init__(self):
|
|
"""Create components for the app."""
|
|
super().__init__()
|
|
|
|
groups = {'i2p': _('Manage I2P application')}
|
|
|
|
info = app_module.Info(app_id=self.app_id, version=version,
|
|
name=_('I2P'), icon_filename='i2p',
|
|
short_description=_('Anonymity Network'),
|
|
description=_description, manual_page='I2P',
|
|
clients=clients)
|
|
self.add(info)
|
|
|
|
menu_item = menu.Menu('menu-i2p', info.name, info.short_description,
|
|
info.icon_filename, 'i2p:index',
|
|
parent_url_name='apps')
|
|
self.add(menu_item)
|
|
|
|
shortcut = frontpage.Shortcut('shortcut-i2p', info.name,
|
|
short_description=info.short_description,
|
|
icon=info.icon_filename, url='/i2p/',
|
|
clients=info.clients,
|
|
login_required=True,
|
|
allowed_groups=list(groups))
|
|
self.add(shortcut)
|
|
|
|
firewall = Firewall('firewall-i2p-web', info.name,
|
|
ports=['http', 'https'], is_external=True)
|
|
self.add(firewall)
|
|
|
|
firewall = Firewall('firewall-i2p-proxies', _('I2P Proxy'),
|
|
ports=tunnels_to_manage.values(),
|
|
is_external=False)
|
|
self.add(firewall)
|
|
|
|
webserver = Webserver('webserver-i2p', 'i2p-freedombox',
|
|
urls=['https://{host}/i2p/'])
|
|
self.add(webserver)
|
|
|
|
daemon = Daemon('daemon-i2p', managed_services[0],
|
|
listen_ports=[(7657, 'tcp6')])
|
|
self.add(daemon)
|
|
|
|
users_and_groups = UsersAndGroups('users-and-groups-i2p',
|
|
groups=groups)
|
|
self.add(users_and_groups)
|
|
|
|
|
|
def init():
|
|
"""Initialize the module."""
|
|
global app
|
|
app = I2PApp()
|
|
|
|
setup_helper = globals()['setup_helper']
|
|
if setup_helper.get_state() != 'needs-setup' and app.is_enabled():
|
|
app.set_enabled(True)
|
|
|
|
|
|
def setup(helper, old_version=None):
|
|
"""Install and configure the module."""
|
|
helper.install(managed_packages)
|
|
|
|
helper.call('post', app.disable)
|
|
# Add favorites to the configuration
|
|
for fav in FAVORITES:
|
|
args = [
|
|
'add-favorite',
|
|
'--name',
|
|
fav.get('name'),
|
|
'--url',
|
|
fav.get('url'),
|
|
]
|
|
if 'icon' in fav:
|
|
args.extend(['--icon', fav.get('icon')])
|
|
|
|
if 'description' in fav:
|
|
args.extend(['--description', fav.get('description')])
|
|
|
|
helper.call('post', actions.superuser_run, 'i2p', args)
|
|
|
|
# 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', app.enable)
|