Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Nov 5, 2023
2 parents 56cb91f + 94211d5 commit 8258e44
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Change log

.. note:: **Upgrade notes**: after upgrading, run the ``arouteserver setup-templates`` command to sync the local templates with those distributed with the new version. More details on the `Upgrading <https://arouteserver.readthedocs.io/en/latest/INSTALLATION.html#upgrading>`__ section of the documentation.

1.21.3
------

- Fix: ``--merge-from-custom-file`` overriding configs from ``clients-from-euroix``.

The ``--merge-from-custom-file`` option of the ``clients-from-euroix`` command is supposed to merge the configurations from a local file into the final content that it generates for clients.yml. However, a bug was triggering an undesired behaviour, for which the ``cfg`` settings from the local file were overriding those automatically generated by the command. This was leading to the removal of information such as max-prefix and as-set that were originally populated using the Euro-IX records.

1.21.2
------

Expand Down
13 changes: 12 additions & 1 deletion pierky/arouteserver/config/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from copy import deepcopy
import logging
import yaml
import collections.abc


from .base import ConfigParserBase, convert_deprecated
from .validators import *
Expand Down Expand Up @@ -300,6 +302,15 @@ def inherit_from_general_cfg(dest, src, schema):
raise ConfigError()

def merge_clients(original, custom_file):

def update_dict_recursively(d, u):
for k, v in u.items():
if isinstance(v, collections.abc.Mapping):
d[k] = update_dict_recursively(d.get(k, {}), v)
else:
d[k] = v
return d

try:
new = yaml.safe_load(custom_file)
except Exception as e:
Expand Down Expand Up @@ -364,7 +375,7 @@ def merge_clients(original, custom_file):
# A client having the same IP is present in the
# list of original clients. It's the one to update
# with the settings from the custom one.
original_client.update(client)
update_dict_recursively(original_client, client)
break
else:
# No clients to update were found.
Expand Down
2 changes: 1 addition & 1 deletion pierky/arouteserver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__version__ = "1.21.3-alpha3" # pragma: no cover
__version__ = "1.21.3-alpha4" # pragma: no cover
COPYRIGHT_YEAR = 2023 # pragma: no cover
2 changes: 2 additions & 0 deletions tests/static/test_clients_from_euroix.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def test_merge_clients_2(self):
ip = "195.69.147.250"
client = [client for client in clients["clients"] if client["ip"] == ip][0]
assert client["cfg"]["filtering"]["irrdb"]["as_sets"] == ["AS-NFLX-V4"]
assert client["cfg"]["filtering"]["max_prefix"]["limit_ipv4"] == 42

ip = "2001:7f8:1::a500:2906:1"
client = [client for client in clients["clients"] if client["ip"] == ip][0]
Expand All @@ -213,6 +214,7 @@ def test_merge_clients_2(self):
ip = "195.69.147.250"
client = [client for client in clients["clients"] if client["ip"] == ip][0]
assert client["cfg"]["filtering"]["irrdb"]["as_sets"] == ["AS-TWO"]
assert client["cfg"]["filtering"]["max_prefix"]["limit_ipv4"] == 42

# In custom_clients_2.yml, the client is reported with
# an uppercase IPv6 address, while the one that comes
Expand Down

0 comments on commit 8258e44

Please sign in to comment.