Skip to content

Commit

Permalink
fix ports
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaundry committed Jan 4, 2025
1 parent 60d9516 commit 9f52f91
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 653 deletions.
14 changes: 12 additions & 2 deletions macos/little_snitch/helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@

def create_rule(process, ports, protocol="tcp", dest_ip=None, dest_host=None, dest_domain=None, owner="me", notes=None):
def create_rule(process, ports=None, protocol="tcp", dest_ip=None, dest_host=None, dest_domain=None, owner="me", notes=None):

rule = {
"action": "allow",
"ports": ports,
"process": process,
"protocol": protocol,
}

if ports is None:
pass
elif type(ports) is str:
rule['ports'] = ports
elif type(ports) is int:
rule['ports'] = str(ports)
elif type(ports) is list:
rule['ports'] = ",".join([str(p) for p in ports])
else:
raise Exception(f"ports has unhandled type, {type(ports)}")

if owner is not None:
rule['owner'] = owner
Expand Down
Loading

0 comments on commit 9f52f91

Please sign in to comment.