Skip to content

Commit f0f9551

Browse files
author
3np
committed
fix nft_cmd construction, adding typing annotation
1 parent 3fdf341 commit f0f9551

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

network/qubes-setup-dnat-to-ns

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
from __future__ import annotations
2323

24+
from typing import List
2425
from itertools import cycle
2526
import subprocess
2627
import sys
2728

2829
import dbus
2930
import qubesdb
30-
from ipaddress import ip_address
31+
from ipaddress import ip_address, IPv4Address, IPv6Address
3132
import os
3233

3334
def get_dns_resolv_conf():
@@ -81,12 +82,12 @@ def get_dns_resolved():
8182

8283
def install_firewall_rules():
8384
qdb = qubesdb.QubesDB()
84-
nft_cmd = []
85-
dns_resolved = get_dns_resolved()
85+
nft_cmd: List[str] = []
86+
dns_resolved: List[IPv4Address | IPv6Address] = get_dns_resolved()
8687
for family in [4, 6]:
8788
ip46 = '6' if family == 6 else ''
8889
dns_servers = [dns_ip for dns_ip in dns_resolved if dns_ip.version == family]
89-
qubesdb_dns = []
90+
qubesdb_dns: List[IPv4Address | IPv6Address] = []
9091
for i in (f"/qubes-netvm-primary-dns{ip46}", f"/qubes-netvm-secondary-dns{ip46}"):
9192
ns_maybe = qdb.read(i)
9293
if ns_maybe is None:
@@ -151,7 +152,7 @@ def install_firewall_rules():
151152
if old_rules == rules:
152153
continue
153154

154-
nft_cmd += [preamble, rules]
155+
nft_cmd += [*preamble, *rules]
155156

156157
if not nft_cmd:
157158
sys.exit(100)

0 commit comments

Comments
 (0)