diff --git a/packages/shared-state-babel_links_info/files/usr/share/shared-state/publishers/shared-state-publish_babel_links_info b/packages/shared-state-babel_links_info/files/usr/share/shared-state/publishers/shared-state-publish_babel_links_info index 443f93399..593ab4606 100755 --- a/packages/shared-state-babel_links_info/files/usr/share/shared-state/publishers/shared-state-publish_babel_links_info +++ b/packages/shared-state-babel_links_info/files/usr/share/shared-state/publishers/shared-state-publish_babel_links_info @@ -5,18 +5,7 @@ -- ! Copyright (c) 2023 Instituto Nacional de Tecnología Industrial -- ! Copyright (C) 2023 Asociación Civil Altermundi -- ! --- ! This program is free software: you can redistribute it and/or modify --- ! it under the terms of the GNU Affero General Public License as --- ! published by the Free Software Foundation, either version 3 of the --- ! License, or (at your option) any later version. --- ! --- ! This program is distributed in the hope that it will be useful, --- ! but WITHOUT ANY WARRANTY; without even the implied warranty of --- ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- ! GNU Affero General Public License for more details. --- ! --- ! You should have received a copy of the GNU Affero General Public License --- ! along with this program. If not, see . +-- ! SPDX-License-Identifier: AGPL-3.0-only local JSON = require("luci.jsonc") local utils = require('lime.utils') @@ -40,11 +29,13 @@ function get_babel_links_info() babelneigt_obj = ubus.call(conn, "babeld", "get_neighbours", {}) if babelneigt_obj ~= nil then for key, value in pairs(babelneigt_obj.IPv6) do - table.insert(links, { + local key_table = {(string.gsub(get_interface_ip(value.dev),":","")),(string.gsub(key,":",""))} + table.sort(key_table) + links[table.concat(key_table)]= { src_ip = get_interface_ip(value.dev), dst_ip = key, iface = value.dev - }) + } end end return links diff --git a/packages/shared-state-babel_links_info/tests/test_shared-state-babel_links_info.lua b/packages/shared-state-babel_links_info/tests/test_shared-state-babel_links_info.lua index 5dff885fa..f4f0d0470 100644 --- a/packages/shared-state-babel_links_info/tests/test_shared-state-babel_links_info.lua +++ b/packages/shared-state-babel_links_info/tests/test_shared-state-babel_links_info.lua @@ -31,9 +31,9 @@ describe('Tests network_nodes #network_nodes', function() require("shared-state-publish_babel_links_info") babelinfo = get_babel_links_info() - assert.are.equal('fe80::16cc:20ff:feda:4eac', babelinfo[1].dst_ip) - assert.are.equal("wlan1-mesh_17",babelinfo[1].iface) - assert.are.equal("fe80::c24a:ff:fefc:3abd",babelinfo[1].src_ip) + assert.are.equal('fe80::16cc:20ff:feda:4eac', babelinfo["fe8016cc20fffeda4eacfe80c24afffefc3abd"].dst_ip) + assert.are.equal("wlan1-mesh_17",babelinfo["fe8016cc20fffeda4eacfe80c24afffefc3abd"].iface) + assert.are.equal("fe80::c24a:ff:fefc:3abd",babelinfo["fe8016cc20fffeda4eacfe80c24afffefc3abd"].src_ip) end) end) diff --git a/packages/shared-state-bat_links_info/files/usr/share/shared-state/publishers/shared-state-publish_bat_links_info b/packages/shared-state-bat_links_info/files/usr/share/shared-state/publishers/shared-state-publish_bat_links_info index 3ddee0e84..9b846b065 100755 --- a/packages/shared-state-bat_links_info/files/usr/share/shared-state/publishers/shared-state-publish_bat_links_info +++ b/packages/shared-state-bat_links_info/files/usr/share/shared-state/publishers/shared-state-publish_bat_links_info @@ -4,18 +4,7 @@ --! Copyright (C) 2023 Javier Jorge --! Copyright (C) 2023 Asociación Civil Altermundi --! ---! This program is free software: you can redistribute it and/or modify ---! it under the terms of the GNU Affero General Public License as ---! published by the Free Software Foundation, either version 3 of the ---! License, or (at your option) any later version. ---! ---! This program is distributed in the hope that it will be useful, ---! but WITHOUT ANY WARRANTY; without even the implied warranty of ---! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ---! GNU Affero General Public License for more details. ---! ---! You should have received a copy of the GNU Affero General Public License ---! along with this program. If not, see . +--! SPDX-License-Identifier: AGPL-3.0-only local JSON = require("luci.jsonc") local utils = require('lime.utils')