|
|
@@ -79,7 +79,9 @@ func (s *Server) Run(ctx context.Context) error {
|
|
|
AuthRequired: true,
|
|
|
}
|
|
|
payload, _ := json.Marshal(resp)
|
|
|
- _, _ = conn.WriteToUDP(payload, remote)
|
|
|
+ if _, err := writeToUDP(conn, payload, remote, packetInfo, net.ParseIP(lan2IP)); err != nil {
|
|
|
+ s.log.Warn("failed to send udp discovery response", "remote", remote.String(), "local_ip", lan2IP, "interface_index", packetInfo.ifIndex, "error", err.Error())
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -89,12 +91,6 @@ type udpPacketInfo struct {
|
|
|
}
|
|
|
|
|
|
func (s *Server) maintenanceEndpoint(packetInfo udpPacketInfo) (string, string) {
|
|
|
- if s.cfg.MaintenanceIP != "" {
|
|
|
- mac := findMACByIP(s.cfg.MaintenanceIP)
|
|
|
- if mac != "" {
|
|
|
- return s.cfg.MaintenanceIP, mac
|
|
|
- }
|
|
|
- }
|
|
|
if packetInfo.ifIndex > 0 {
|
|
|
lan2IP, mac := findLinkLocalEndpointByInterfaceIndex(packetInfo.ifIndex)
|
|
|
if lan2IP != "" {
|
|
|
@@ -107,6 +103,12 @@ func (s *Server) maintenanceEndpoint(packetInfo udpPacketInfo) (string, string)
|
|
|
return lan2IP, mac
|
|
|
}
|
|
|
}
|
|
|
+ if s.cfg.MaintenanceIP != "" {
|
|
|
+ mac := findMACByIP(s.cfg.MaintenanceIP)
|
|
|
+ if mac != "" {
|
|
|
+ return s.cfg.MaintenanceIP, mac
|
|
|
+ }
|
|
|
+ }
|
|
|
return findFirstLinkLocalEndpoint()
|
|
|
}
|
|
|
|