mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
Fixes 2 related issues: 1. wsconncache had incorrect logic to test whether to send DERPMap updates, sending if the maps were equivalent, instead of if they were _not equivalent_. 2. configmaps used a bugged check to test equality between DERPMaps, since it contains a map and the map entries are serialized in random order. Instead, we avoid comparing the protobufs and instead depend on the existing function that compares `tailcfg.DERPMap`. This also has the effect of reducing the number of times we convert to and from protobuf.
21 lines
375 B
Go
21 lines
375 B
Go
package proto
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
gProto "google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// Equal returns true if the nodes have the same contents
|
|
func (s *Node) Equal(o *Node) (bool, error) {
|
|
sBytes, err := gProto.Marshal(s)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
oBytes, err := gProto.Marshal(o)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return bytes.Equal(sBytes, oBytes), nil
|
|
}
|