UDP transport with broadcast support, -udp and -iface flags on info

This commit is contained in:
Ian Gulliver
2026-04-07 21:44:35 +09:00
parent 9989d8c66a
commit 7034391d4d
2 changed files with 72 additions and 7 deletions

View File

@@ -73,12 +73,16 @@ func printInfo(dev string, info *client.ResponseInfo) {
func cmdInfo(args []string) error {
fs := flag.NewFlagSet("info", flag.ExitOnError)
udpAddr := fs.String("udp", "", "connect via UDP to this IP address")
iface := fs.String("iface", "", "bind to this network interface (for broadcast)")
fs.Parse(args)
if *udpAddr != "" {
log := slog.With("addr", *udpAddr)
if *iface != "" {
log = log.With("iface", *iface)
}
log.Info("connecting via UDP")
c, err := client.NewUDP(*udpAddr, 2*time.Second)
c, err := client.NewUDP(*udpAddr, *iface, 2*time.Second)
if err != nil {
return err
}