Browse Source

import re, don't pass through None protocol & fix completely broken ip regex

tags/v0.2.0
Mike Campbell 8 years ago
parent
commit
7490f9b9a0
3 changed files with 7 additions and 2 deletions
  1. +3
    -0
      _modules/ufw.py
  2. +2
    -2
      _states/ufw.py
  3. +2
    -0
      ufw/init.sls

+ 3
- 0
_modules/ufw.py View File

@@ -1,6 +1,9 @@
"""
Execution module for UFW.
"""

import re

def is_enabled():
cmd = 'ufw status | grep "Status: active"'
out = __salt__['cmd.run'](cmd, python_shell=True)

+ 2
- 2
_states/ufw.py View File

@@ -20,8 +20,8 @@ def _changed(name, msg, **changes):


def _resolve(host):
# pure IP address / netmask IPv4 or IPv6 ?
if re.match(r'^([0-9\.](::))+(/[0-9]+)?$', host):
# let's just see if it starts with a number or a colon, for simplicity
if re.match(r'^[0-9:]', host):
return

return socket.gethostbyname(host)

+ 2
- 0
ufw/init.sls View File

@@ -38,7 +38,9 @@ ufw-default-outgoing:

ufw-svc-{{service_name}}-{{from_addr}}:
ufw.allowed:
{%- if protocol != None %}
- protocol: {{protocol}}
{%- endif %}
{%- if from_addr != None %}
- from_addr: {{from_addr}}
{%- endif %}

Loading…
Cancel
Save