1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
import validations
from Page import *
from Table import *
from Entry import *
from Form import *
PRODUCT_TOKENS = [
('', 'Default'),
('product', 'Product only'),
('minor', 'Product + Minor version'),
('minimal', 'Product + Minimal version'),
('os', 'Product + Platform'),
('full', 'Full Server string')
]
DATA_VALIDATION = [
("server!keepalive", validations.is_boolean),
("server!ipv6", validations.is_boolean),
("server!port.*", validations.is_tcp_port),
("server!listen", validations.is_ip),
("server!chroot", (validations.is_local_dir_exists, 'cfg')),
]
NOTE_PORT = 'Defines the port that the server will listens to'
NOTE_PORT_TLS = 'Defines the port that the server will listens to for secure connections'
NOTE_IPV6 = 'Set to enable the IPv6 support. The OS must support IPv6 for this to work.'
NOTE_LISTEN = 'IP address of the interface to bind. It usually is empty.'
NOTE_TIMEOUT = 'Time interval until the server closes inactive connections.'
NOTE_KEEPALIVE = 'Enables the server-wide keep-alive support. It increases the performance, it is usually set on.'
NOTE_TOKENS = 'This option allow to choose how the server identify itself.'
NOTE_USER = 'Changes the effective user. User names and IDs are accepted.'
NOTE_GROUP = 'Changes the effective group. Group names and IDs are accepted.'
NOTE_CHROOT = 'Jail the server inside the directory. Don\'t use it as the only security measure.'
class PageGeneral (PageMenu, FormHelper):
def __init__ (self, cfg):
PageMenu.__init__ (self, 'general', cfg)
FormHelper.__init__ (self, 'general', cfg)
def _op_render (self):
content = self._render_content()
self.AddMacroContent ('title', 'General configuration')
self.AddMacroContent ('content', content)
return Page.Render(self)
def _render_content (self):
txt = "<h1>General Settings</h1>"
txt += "<h2>Networking</h2>"
table = TableProps()
self.AddPropEntry (table, 'Port', 'server!port', NOTE_PORT)
self.AddPropEntry (table, 'Port TLS', 'server!tls_port', NOTE_PORT_TLS)
self.AddPropCheck (table, 'IPv6', 'server!ipv6', True, NOTE_IPV6)
self.AddPropEntry (table, 'Listen', 'server!listen', NOTE_LISTEN)
txt += self.Indent(table)
txt += "<h2>Basic Behaviour</h2>"
table = TableProps()
self.AddPropEntry (table, 'Timeout (<i>secs</i>)', 'server!timeout', NOTE_TIMEOUT)
self.AddPropCheck (table, 'Keep Alive', 'server!keepalive', True, NOTE_KEEPALIVE)
self.AddPropOptions(table, 'Server Tokens', 'server!server_tokens', PRODUCT_TOKENS, NOTE_TOKENS)
txt += self.Indent(table)
txt += "<h2>Server Permissions</h2>"
table = TableProps()
self.AddPropEntry (table, 'User', 'server!user', NOTE_USER)
self.AddPropEntry (table, 'Group', 'server!group', NOTE_GROUP)
self.AddPropEntry (table, 'Chroot', 'server!chroot', NOTE_CHROOT)
txt += self.Indent(table)
form = Form ("/%s" % (self._id))
return form.Render(txt,DEFAULT_SUBMIT_VALUE)
def _op_apply_changes (self, uri, post):
self.ApplyChanges (['server!ipv6', 'server!keepalive'], post,
validation = DATA_VALIDATION)
|