]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/libloc-0.9.1-export-flagged-networks-with-their-faked-country-names-too.patch
Add convert-to-location converter.
[ipfire-2.x.git] / src / patches / libloc-0.9.1-export-flagged-networks-with-their-faked-country-names-too.patch
CommitLineData
4415b1c3
SS
1commit fae36e81a32717ac43c0ce48702f6ff05b7cd029
2Author: Michael Tremer <michael.tremer@ipfire.org>
3Date: Fri Jun 5 09:57:41 2020 +0000
4
5 export flagged networks with their faked country names, too
6
7 This will lead to some networks showing up twice. Once with
8 their real country and once with their faked one.
9
10 It is likely that the first one will match.
11
12 Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
13
14diff --git a/src/python/export.py b/src/python/export.py
15index 69fe964..d0bbe77 100644
16--- a/src/python/export.py
17+++ b/src/python/export.py
18@@ -23,10 +23,18 @@ import logging
19 import os
20 import socket
21
22+import _location
23+
24 # Initialise logging
25 log = logging.getLogger("location.export")
26 log.propagate = 1
27
28+flags = {
29+ _location.NETWORK_FLAG_ANONYMOUS_PROXY : "A1",
30+ _location.NETWORK_FLAG_SATELLITE_PROVIDER : "A2",
31+ _location.NETWORK_FLAG_ANYCAST : "A3",
32+}
33+
34 class OutputWriter(object):
35 suffix = "networks"
36 mode = "w"
37@@ -173,6 +181,17 @@ class Exporter(object):
38 except KeyError:
39 pass
40
41+ # Handle flags
42+ for flag in flags:
43+ if network.has_flag(flag):
44+ # Fetch the "fake" country code
45+ country = flags[flag]
46+
47+ try:
48+ writers[country].write(network)
49+ except KeyError:
50+ pass
51+
52 # Write everything to the filesystem
53 for writer in writers.values():
54 writer.finish()