Per-packet source tracking in transport, via/from in info output

This commit is contained in:
Ian Gulliver
2026-04-07 22:30:26 +09:00
parent f96ed20aa0
commit 3d20bf4c33
4 changed files with 41 additions and 37 deletions

View File

@@ -50,9 +50,10 @@ type deviceResult struct {
err error
}
func printInfo(dev string, info *client.ResponseInfo) {
func printInfo(via string, from string, info *client.ResponseInfo) {
slog.Info("device",
"dev", dev,
"via", via,
"from", from,
"board_id", hex.EncodeToString(info.BoardID[:]),
"mac", net.HardwareAddr(info.MAC[:]).String(),
"ip", net.IP(info.IP[:]).String(),
@@ -86,8 +87,8 @@ func cmdInfo(args []string) error {
if len(infos) == 0 {
return fmt.Errorf("no devices responded")
}
for _, info := range infos {
printInfo(net.IP(info.IP[:]).String(), info)
for _, r := range infos {
printInfo(*udpAddr, r.From, r.Value)
}
return nil
}
@@ -126,7 +127,7 @@ func cmdInfo(args []string) error {
slog.Error("device error", "dev", r.dev, "err", r.err)
continue
}
printInfo(r.dev, r.info)
printInfo(r.dev, r.dev, r.info)
}
return nil