firewall: mark an IP as handled in /qubes-firewall_handled/[ip] after
each handling iteration Actually a counter is increased after each handling iteration. This is useful for user applications to remain up to date with the changes implemented by the Qubes firewall.
This commit is contained in:
parent
dda500b837
commit
78de37da92
@ -143,6 +143,19 @@ class FirewallWorker(object):
|
||||
for host, hostaddrs in dns.items():
|
||||
self.qdb.write('/dns/{}/{}'.format(source, host), str(hostaddrs))
|
||||
|
||||
def update_handled(self, addr):
|
||||
"""
|
||||
Update the QubesDB count of how often the given address was handled.
|
||||
User applications may watch these paths for count increases to remain
|
||||
up to date with QubesDB changes.
|
||||
"""
|
||||
cnt = self.qdb.read('/qubes-firewall_handled/{}'.format(addr))
|
||||
try:
|
||||
cnt = int(cnt)
|
||||
except (TypeError, ValueError):
|
||||
cnt = 0
|
||||
self.qdb.write('/qubes-firewall_handled/{}'.format(addr), str(cnt+1))
|
||||
|
||||
def list_targets(self):
|
||||
return set(t.split('/')[2] for t in self.qdb.list('/qubes-firewall/'))
|
||||
|
||||
@ -179,6 +192,8 @@ class FirewallWorker(object):
|
||||
self.log_error(
|
||||
'Failed to block traffic for {}'.format(addr))
|
||||
|
||||
self.update_handled(addr)
|
||||
|
||||
@staticmethod
|
||||
def dns_addresses(family=None):
|
||||
with open('/etc/resolv.conf') as resolv:
|
||||
|
Loading…
Reference in New Issue
Block a user