def login(message: Union[None, str] = None, messagetype: Union[None, str] = None) -> str: """ Return the login page which shows messages. also the function updates the last commit informations in the config file """ utils = Webutils() utils.update_last_commit_infos() payload = utils.get_default_payload("Signin", "signin") if messagetype is not None: payload.messagetype = messagetype if message is not None: payload.message = message return render_template('login.html', vars=payload)
def blacklist(saved: bool = False) -> str: """Return the blacklist page when the user is logged in.""" utils = Webutils() rules = RulesHandler() if utils.check_login(request) is True: payload = utils.get_default_payload("Blacklist") payload.lead = """ On this page you can list IP addresses that are not allowed to connect to this machine. <br /> Please check the IP addresses carefully, as they are not checked by easywall.<br /> You can add IPv4 and IPv6 addresses to the list. """ payload.addresses = rules.get_rules_for_web("blacklist") payload.custom = rules.diff_new_current("blacklist") payload.saved = saved return render_template('blacklist.html', vars=payload) return login()
def custom(saved: bool = False) -> str: """the function returns the custom rules page when the user is logged in""" utils = Webutils() rules = RulesHandler() if utils.check_login(request) is True: payload = utils.get_default_payload("Custom") payload.lead = """ On this page you can add your own firewall rules.<br /> Please check the rules for accuracy, as these are not tested by easywall.<br /> <br /> To add your own rule, simply copy the rule into the text box. One rule per line.<br /> It is important to omit the iptables command.<br /> Example: <code>-P FORWARD DROP</code> """ payload.rules = rules.get_rules_for_web("custom") payload.custom = rules.diff_new_current("custom") payload.saved = saved return render_template('custom.html', vars=payload) return login()
def forwarding(saved: bool = False) -> str: """TODO: Doku.""" utils = Webutils() rules = RulesHandler() if utils.check_login(request): payload = utils.get_default_payload("Port Forwarding") payload.lead = """ This page allows you to forward ports from the local system to ports on the Internet.<br /> This is especially useful if the port of an application cannot be changed.<br /> Enter the port type, source and destination.<br /> You do not have to release the public port separately, easywall will do that for you. """ payload.forwardings = rules.get_rules_for_web("forwarding") payload.custom = False if rules.diff_new_current("forwarding"): payload.custom = True payload.saved = saved return render_template('forwarding.html', vars=payload) return login()
def options(saved: bool = False, error: str = "", active_tab: str = "iptables") -> str: """Return the options page when the user is logged in.""" utils = Webutils() if utils.check_login(request) is True: payload = utils.get_default_payload("Options") payload.lead = """ On this page you can configure easywall.<br /> All entries from the configuration files for the core and the web interface are available.<br /> Some entries require a restart of the respective program part. """ payload.config = utils.cfg_easywall payload.config_web = utils.cfg payload.config_log = utils.cfg_log payload.saved = saved payload.error = error payload.active_tab = active_tab return render_template('options.html', vars=payload) return login()
def apply(saved: bool = False, step: int = 1) -> str: """ the function returns the apply page when the user is logged in """ utils = Webutils() if utils.check_login(request) is True: payload = utils.get_default_payload("Apply") payload.lead = """ The defined firewall rules were not automatically activated for security reasons.<br> On this page, you can safely apply the defined rules.<br> The activation takes place in two steps and an exclusion from the server should be prevented. """ payload.saved = saved payload.step = step payload.lastapplied = utils.get_last_accept_time() payload.running = step > 1 payload.accepttime = str( utils.cfg_easywall.get_value("ACCEPTANCE", "duration")) return render_template('apply.html', vars=payload) return login()
def ports(saved: bool = False) -> str: """Return the ports page when the user is logged in.""" utils = Webutils() rules = RulesHandler() if utils.check_login(request) is True: payload = utils.get_default_payload("Open Ports") payload.lead = """ On this page you can open ports for incoming connections.<br /> You can add tcp and udp ports.<br /> Please check whether the entries in the list are needed in the future and remove old entries if they are no longer needed.<br /> To list all open ports under Linux use the command <code>netstat -ln</code> """ payload.tcp = natsorted(rules.get_rules_for_web("tcp"), key=itemgetter(*['port'])) payload.udp = natsorted(rules.get_rules_for_web("udp"), key=itemgetter(*['port'])) payload.custom = False if rules.diff_new_current("tcp") is True or rules.diff_new_current("udp") is True: payload.custom = True payload.saved = saved return render_template('ports.html', vars=payload) return login()
def index() -> str: """Return the index page when the user is logged in.""" utils = Webutils() if utils.check_login(request) is True: return render_template('index.html', vars=utils.get_default_payload("Home")) return login()