Skip to content

Commit

Permalink
Add a protection to avoid autoban themself if we change the default a…
Browse files Browse the repository at this point in the history
…jenti port
  • Loading branch information
Xefir committed Feb 24, 2016
1 parent ba2e7b1 commit 5046fa4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ajenti/plugins/iptables/main.py
Expand Up @@ -3,6 +3,7 @@
import itertools
import subprocess

import ajenti
from ajenti.api import *
from ajenti.plugins.main.api import SectionPlugin
from ajenti.ui import on
Expand Down Expand Up @@ -121,7 +122,7 @@ def post_rule_update(o, c, i, u):
def on_page_load(self):
if not os.path.exists(self.fw_mgr.config_path_ajenti):
if not os.path.exists(self.fw_mgr.config_path):
open(self.fw_mgr.config_path, 'w').write("""
TEMPLATE_IPTABLES_CONTENT = """
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
Expand All @@ -142,9 +143,12 @@ def on_page_load(self):
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
-A INPUT -p tcp -m tcp --dport %(ajenti_port)s -j ACCEPT
COMMIT
""")
"""
open(self.fw_mgr.config_path, 'w').write(TEMPLATE_IPTABLES_CONTENT % {
'ajenti_port': ajenti.config.tree.http_binding.port
})
open(self.fw_mgr.config_path_ajenti, 'w').write(open(self.fw_mgr.config_path).read())
self.config.load()
self.refresh()
Expand Down Expand Up @@ -265,7 +269,6 @@ def get_template(self, item, ui):
return root



if subprocess.call(['which', 'ip6tables']) == 0:
@interface
class IPv6FirewallManager (object):
Expand Down

0 comments on commit 5046fa4

Please sign in to comment.