Merge pull request #12 from titoko/dev

Upnp Cron
This commit is contained in:
Alexis Gavoty 2013-03-13 05:37:39 -07:00
commit 408be5dfa6
3 changed files with 34 additions and 4 deletions

View file

@ -491,6 +491,14 @@ firewall:
action: store_true action: store_true
### firewall_installupnp()
installupnp:
action_help: Add upnp cron
### firewall_removeupnp()
removeupnp:
action_help: Remove upnp cron
############################# #############################
# Tools # # Tools #
############################# #############################

View file

@ -1,6 +1,6 @@
ipv4: ipv4:
TCP: [22, 25, 53, 80, 443, 5222, 5269, 5280] TCP: [22, 25, 53, 80, 443, 5222, 5269, 5280]
UDP: [] UDP: [53]
ipv6: ipv6:
TCP: [22] TCP: [22]
UDP: [] UDP: [53]

View file

@ -128,6 +128,7 @@ def firewall_reload(upnp=False):
os.system ("iptables -P INPUT DROP") os.system ("iptables -P INPUT DROP")
os.system ("ip6tables -P INPUT DROP") os.system ("ip6tables -P INPUT DROP")
os.system("service fail2ban restart")
win_msg(_("Firewall successfully reloaded")) win_msg(_("Firewall successfully reloaded"))
@ -217,3 +218,24 @@ def add_portmapping(protocol=None, upnp=False, ipv6=None):
upnp.addportmapping(port, protocol, upnp.lanaddr, port, 'yunohost firewall : port %u' % port, '') upnp.addportmapping(port, protocol, upnp.lanaddr, port, 'yunohost firewall : port %u' % port, '')
os.system ("iptables -P INPUT DROP") os.system ("iptables -P INPUT DROP")
def firewall_installupnp():
"""
Add upnp cron
Keyword arguments:
None
Return
None
"""
os.system("touch /etc/cron.d/yunohost-firewall")
os.system("echo '*/50 * * * * root yunohost firewall reload -u>>/dev/null'>/etc/cron.d/yunohost-firewall")
win_msg(_("UPNP cron installed"))
def firewall_removeupnp():
try:
os.remove("/etc/cron.d/yunohost-firewall")
except:
raise YunoHostError(167,_("UPNP cron was not installed!"))
win_msg(_("UPNP cron removed"))