Skip to content
Merged
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
18 changes: 16 additions & 2 deletions packages/ns-api/files/ns.nat
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cmd = sys.argv[1]
if cmd == 'list':
print(json.dumps({
'list-rules': {},
'list-devices': {},
'add-rule': {
"name": "r1",
"src": "lan",
Expand All @@ -43,6 +44,17 @@ elif cmd == 'call':
e_uci = EUci()
if action == 'list-rules':
print(json.dumps({'rules': firewall.list_nat_rules(e_uci)}))
elif action == 'list-devices':
devices = []
for zone in firewall.list_zones(e_uci).values():
for device in utils.get_all_devices_by_zone(e_uci, zone.get('name')):
devices.append({
'id': device,
'label': utils.get_interface_from_device(e_uci, device)
})
json.dump({
'devices': devices,
}, sys.stdout)
elif action == "add-rule":
data = json.JSONDecoder().decode(sys.stdin.read())
ret = firewall.add_nat_rule(
Expand All @@ -52,7 +64,8 @@ elif cmd == 'call':
data['src'],
data['src_ip'],
data['dest_ip'],
data['snat_ip']
data['snat_ip'],
data['device'],
)
print(json.dumps({"id": ret}))
elif action == "edit-rule":
Expand All @@ -65,7 +78,8 @@ elif cmd == 'call':
data['src'],
data['src_ip'],
data['dest_ip'],
data['snat_ip']
data['snat_ip'],
data['device'],
)
print(json.dumps({"id": ret}))
elif action == "delete-rule":
Expand Down
2 changes: 1 addition & 1 deletion packages/python3-nethsec/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=python3-nethsec
PKG_VERSION:=1.0.1
PKG_VERSION:=1.1.0
PKG_RELEASE:=1

PKG_MAINTAINER:=Giacomo Sanchietti <giacomo.sanchietti@nethesis.it>
Expand Down
Loading