diff --git a/package/emortal/autocore/Makefile b/package/emortal/autocore/Makefile index 65a6e13ecd..44c2b792d7 100644 --- a/package/emortal/autocore/Makefile +++ b/package/emortal/autocore/Makefile @@ -50,7 +50,6 @@ endif $(CP) ./files/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/ ifeq ($(filter ipq806x%, $(TARGETID)),) - $(INSTALL_BIN) ./files/ethinfo $(1)/sbin/ $(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include $(INSTALL_DATA) ./files/29_ethinfo.js $(1)/www/luci-static/resources/view/status/include/ endif diff --git a/package/emortal/autocore/files/29_ethinfo.js b/package/emortal/autocore/files/29_ethinfo.js index 8c769fd597..69bf6cbbaf 100644 --- a/package/emortal/autocore/files/29_ethinfo.js +++ b/package/emortal/autocore/files/29_ethinfo.js @@ -7,9 +7,9 @@ 'require network'; 'require firewall'; -var callLuciETHInfo = rpc.declare({ - object: 'luci', - method: 'getETHInfo', +var callNetworkStatus = rpc.declare({ + object: 'network.device', + method: 'status', expect: { '': {} } }); @@ -292,7 +292,7 @@ return baseclass.extend({ load: function() { return Promise.all([ - L.resolveDefault(callLuciETHInfo(), {}), + L.resolveDefault(callNetworkStatus(), {}), firewall.getZones(), network.getNetworks(), uci.load('network') @@ -303,11 +303,13 @@ return baseclass.extend({ var known_ports = [], port_map = buildInterfaceMapping(data[1], data[2]); - if (Array.isArray(data[0].ethinfo)) - data[0].ethinfo.forEach((k) => known_ports.push({ - device: k, - netdev: network.instantiateDevice(k) - })); + Object.keys(data[0]).forEach((k) => { + if (['dsa', 'ethernet'].includes(data[0][k].devtype) && data[0][k]['link-advertising'].length) + known_ports.push({ + device: k, + netdev: network.instantiateDevice(k) + }); + }); known_ports.sort(function(a, b) { return L.naturalCompare(a.device, b.device); diff --git a/package/emortal/autocore/files/ethinfo b/package/emortal/autocore/files/ethinfo deleted file mode 100755 index 52af8a9b47..0000000000 --- a/package/emortal/autocore/files/ethinfo +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/ucode -/* Copyright (C) 2022 ImmortalWrt.org */ - -'use strict'; - -import { connect } from 'ubus'; - -const ubus = connect(); -const stat = ubus.call('network.device', 'status', {}); -if (!stat) { - print('{}'); - exit(1); -} - -let device_list = []; -map(keys(stat), (ifname) => { - if (ifname && stat[ifname]?.devtype in ['ethernet', 'dsa'] && length(stat[ifname]['link-advertising'])) - push(device_list, ifname); -}); - -sort(device_list, (a, b) => { - return a > b; -}); - -print(device_list); diff --git a/package/emortal/autocore/files/luci-mod-status-autocore.json b/package/emortal/autocore/files/luci-mod-status-autocore.json index c9b930e1da..5dfd32fad9 100644 --- a/package/emortal/autocore/files/luci-mod-status-autocore.json +++ b/package/emortal/autocore/files/luci-mod-status-autocore.json @@ -3,7 +3,8 @@ "description": "Grant access to autocore", "read": { "ubus": { - "luci": [ "getCPUInfo", "getETHInfo", "getTempInfo" ] + "luci": [ "getCPUInfo", "getTempInfo" ], + "network.device": [ "status" ] } } }