mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
Closes: #729. Tests: - Install Shadowsocks Server. Install Shadowsocks Client, and set the server to localhost, and set the same password as the server. Use curl to connect to local SOCKS proxy on port 1080 and fetch a website. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Update some docstring comments for shadowsocks clients] [sunil: Use the term Censorship instead of network filters] [sunil: Prevent enabling both apps when setup is re-run] [sunil: Update typehint for a privileged method to be minimal] [sunil: Accept connections from external IPs too] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""FreedomBox app for configuring Shadowsocks Client."""
|
|
|
|
from django import forms
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from plinth.modules.shadowsocksserver.forms import METHODS
|
|
|
|
|
|
class TrimmedCharField(forms.CharField):
|
|
"""Trim the contents of a CharField."""
|
|
|
|
def clean(self, value):
|
|
"""Clean and validate the field value."""
|
|
if value:
|
|
value = value.strip()
|
|
|
|
return super().clean(value)
|
|
|
|
|
|
class ShadowsocksForm(forms.Form):
|
|
"""Shadowsocks Client configuration form."""
|
|
|
|
server = TrimmedCharField(label=_('Server'),
|
|
help_text=_('Server hostname or IP address'))
|
|
|
|
server_port = forms.IntegerField(label=_('Server port'), min_value=0,
|
|
max_value=65535,
|
|
help_text=_('Server port number'))
|
|
|
|
password = forms.CharField(
|
|
label=_('Password'), help_text=_('Password used to encrypt data. '
|
|
'Must match server password.'))
|
|
|
|
method = forms.ChoiceField(
|
|
label=_('Method'), choices=METHODS,
|
|
help_text=_('Encryption method. Must match setting on server.'))
|