netcfg: UDP socket listing + routes/count node

- UDP sockets now enumerated in /scheme/netcfg/sockets/list:
    udp: local=0.0.0.0:53
    udp: local=127.0.0.1:8080
- New RouteTable::len() method + /scheme/netcfg/route/count:
    cat /scheme/netcfg/route/count  →  'routes: 4'

Complete connections view now covers TCP + UDP listening sockets,
plus route count summary for at-a-glance monitoring.
This commit is contained in:
Red Bear OS
2026-07-08 18:19:42 +03:00
parent 0725f81144
commit 89083a25f9
2 changed files with 19 additions and 0 deletions
+4
View File
@@ -130,6 +130,10 @@ impl RouteTable {
rule.src = new_src;
}
}
pub fn len(&self) -> usize {
self.rules.len()
}
}
impl Display for RouteTable {
+15
View File
@@ -183,6 +183,15 @@ fn mk_root_node(
local.map(|e| format!("{}", e)).unwrap_or_else(|| "-".to_string()),
remote.map(|e| format!("{}", e)).unwrap_or_else(|| "-".to_string())));
}
if let smoltcp::socket::Socket::Udp(udp_sock) = socket {
let endpoint = udp_sock.endpoint();
out.push_str(&format!("udp: local={}\n",
if endpoint.port != 0 {
format!("{}", endpoint)
} else {
"-".to_string()
}));
}
}
out
}
@@ -251,6 +260,12 @@ fn mk_root_node(
format!("{}", route_table.borrow())
}
},
"count" => {
ro [route_table] || {
let count = route_table.borrow().len();
format!("routes: {}\n", count)
}
},
"add" => {
wo [iface, notifier, route_table] (Option<Rule>, None)
|cur_value, line| {