Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions _states/ufw.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ def _changed(name, msg, **changes):


def _resolve(host):
# pure IP address / netmask IPv4 or IPv6 ?
if re.match(r'^([0-9\.](::))+(/[0-9]+)?$', host):
return
# pure IP address / netmask IPv4?
if re.match(r'^([0-9\.])+(/[0-9]+)?$', host):
return host

# pure IPv6 address / netmask?
if re.match(r'^([0-9a-f:]+)(/[0-9]+)?$', host):
return host

return socket.gethostbyname(host)

Expand Down
4 changes: 2 additions & 2 deletions ufw/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ ufw-svc-{{service_name}}-{{from_addr}}:
ufw.allowed:
- protocol: {{protocol}}
{%- if from_addr != None %}
- from_addr: {{from_addr}}
- from_addr: "{{from_addr}}"
{%- endif %}
{%- if from_port != None %}
- from_port: "{{from_port}}"
{%- endif %}
{%- if to_addr != None %}
- to_addr: {{to_addr}}
- to_addr: "{{to_addr}}"
{%- endif %}
- to_port: "{{service_name}}"
- require:
Expand Down