mirror of
https://github.com/Rudd-O/qubes-network-server.git
synced 2025-03-01 14:22:35 +01:00
Beware that qdb now returns bytes instead of strings.
This commit is contained in:
parent
b92f096dcc
commit
42c527c179
@ -18,6 +18,10 @@ import subprocess
|
|||||||
import qubesdb
|
import qubesdb
|
||||||
|
|
||||||
|
|
||||||
|
def _s(v):
|
||||||
|
if isinstance(v, bytes):
|
||||||
|
return v.decode("utf-8")
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
FORWARD_ROUTING_METHOD = "forward"
|
FORWARD_ROUTING_METHOD = "forward"
|
||||||
@ -191,7 +195,7 @@ class AdjunctWorker(object):
|
|||||||
|
|
||||||
def handle_addr(self, addr):
|
def handle_addr(self, addr):
|
||||||
# Setup plain forwarding for this specific address.
|
# Setup plain forwarding for this specific address.
|
||||||
routing_method = self.qdb.read('/qubes-routing-method/{}'.format(addr))
|
routing_method = _s(self.qdb.read("/qubes-routing-method/{}".format(addr)))
|
||||||
self.setup_plain_forwarding_for_address(
|
self.setup_plain_forwarding_for_address(
|
||||||
addr,
|
addr,
|
||||||
routing_method == FORWARD_ROUTING_METHOD,
|
routing_method == FORWARD_ROUTING_METHOD,
|
||||||
@ -200,7 +204,8 @@ class AdjunctWorker(object):
|
|||||||
|
|
||||||
# Manipulate proxy ARP for all known addresses.
|
# Manipulate proxy ARP for all known addresses.
|
||||||
methods = [
|
methods = [
|
||||||
(k.split('/')[2], v) for k, v in self.qdb.multiread('/qubes-routing-method/').items()
|
(_s(k).split("/")[2], _s(v))
|
||||||
|
for k, v in self.qdb.multiread("/qubes-routing-method/").items()
|
||||||
]
|
]
|
||||||
mmethods = {
|
mmethods = {
|
||||||
4: [m[1] for m in methods if not self.is_ip6(m[0])],
|
4: [m[1] for m in methods if not self.is_ip6(m[0])],
|
||||||
@ -212,7 +217,7 @@ class AdjunctWorker(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def list_targets(self):
|
def list_targets(self):
|
||||||
return set(t.split('/')[2] for t in self.qdb.list('/qubes-routing-method/'))
|
return set(_s(t).split("/")[2] for t in self.qdb.list("/qubes-routing-method/"))
|
||||||
|
|
||||||
def sd_notify(self, state):
|
def sd_notify(self, state):
|
||||||
"""Send notification to systemd, if available"""
|
"""Send notification to systemd, if available"""
|
||||||
@ -240,7 +245,8 @@ class AdjunctWorker(object):
|
|||||||
for watch_path in iter(self.qdb.read_watch, None):
|
for watch_path in iter(self.qdb.read_watch, None):
|
||||||
# ignore writing rules itself - wait for final write at
|
# ignore writing rules itself - wait for final write at
|
||||||
# source_addr level empty write (/qubes-firewall/SOURCE_ADDR)
|
# source_addr level empty write (/qubes-firewall/SOURCE_ADDR)
|
||||||
if watch_path.count('/') != 2:
|
watch_path = s(watch_path)
|
||||||
|
if watch_path.count("/") != 2:
|
||||||
continue
|
continue
|
||||||
source_addr = watch_path.split("/")[2]
|
source_addr = watch_path.split("/")[2]
|
||||||
self.handle_addr(source_addr)
|
self.handle_addr(source_addr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user