Pass pointer to ViaSender

This commit is contained in:
Nate Brown
2025-11-22 00:42:25 -06:00
parent 04f47eabf7
commit 4eb808c829
6 changed files with 13 additions and 13 deletions

View File

@@ -285,14 +285,14 @@ type ViaSender struct {
IsRelayed bool // IsRelayed is true if the packet was sent through a relay
}
func (v ViaSender) String() string {
func (v *ViaSender) String() string {
if v.IsRelayed {
return fmt.Sprintf("%s (relayed)", v.UdpAddr)
}
return v.UdpAddr.String()
}
func (v ViaSender) MarshalJSON() ([]byte, error) {
func (v *ViaSender) MarshalJSON() ([]byte, error) {
if v.IsRelayed {
return json.Marshal(m{"direct": v.UdpAddr})
}
@@ -723,7 +723,7 @@ func (i *HostInfo) SetRemote(remote netip.AddrPort) {
// SetRemoteIfPreferred returns true if the remote was changed. The lastRoam
// time on the HostInfo will also be updated.
func (i *HostInfo) SetRemoteIfPreferred(hm *HostMap, via ViaSender) bool {
func (i *HostInfo) SetRemoteIfPreferred(hm *HostMap, via *ViaSender) bool {
if via.IsRelayed {
return false
}