Procházet zdrojové kódy

Merge pull request #2 from DEnet/interface-support

Interface support
tags/v0.2.0
Mario del Pozo před 9 roky
rodič
revize
032db699f4
3 změnil soubory, kde provedl 22 přidání a 3 odebrání
  1. +7
    -3
      _states/ufw.py
  2. +4
    -0
      pillar.example
  3. +11
    -0
      ufw/init.sls

+ 7
- 3
_states/ufw.py Zobrazit soubor

@@ -27,10 +27,14 @@ def _resolve(host):
return socket.gethostbyname(host)


def _as_rule(method, app, protocol, from_addr, from_port, to_addr, to_port):
def _as_rule(method, app, interface, protocol, from_addr, from_port, to_addr, to_port):
cmd = [method]
if app is not None:
cmd.append(app)
elif interface is not None:
cmd.append("in")
cmd.append("on")
cmd.append(interface)
else:
if protocol is not None:
cmd.append("proto")
@@ -74,10 +78,10 @@ def enabled(name, **kwargs):
return _changed(name, "UFW is enabled", enabled=True)


def allowed(name, app=None, protocol=None,
def allowed(name, app=None, interface=None, protocol=None,
from_addr=None, from_port=None, to_addr=None, to_port=None):

rule = _as_rule("allow", app=app, protocol=protocol,
rule = _as_rule("allow", app=app, interface=interface, protocol=protocol,
from_addr=from_addr, from_port=from_port, to_addr=to_addr, to_port=to_port)

if __opts__['test']:

+ 4
- 0
pillar.example Zobrazit soubor

@@ -37,3 +37,7 @@ ufw:
# Allow an application defined at /etc/ufw/applications.d/
applications:
- OpenSSH

# Allow all traffic in on the specified interface
interfaces:
- eth1

+ 11
- 0
ufw/init.sls Zobrazit soubor

@@ -50,6 +50,17 @@ ufw-app-{{app_name}}:
- pkg: ufw

{%- endfor %}
# Interfaces
{%- for interface in ufw.get('interfaces', []) %}

ufw-interface-{{interface}}:
ufw.allowed:
- interface: {{interface}}
- require:
- pkg: ufw

{%- endfor %}

{% else %}
#ufw:

Načítá se…
Zrušit
Uložit