diff --git a/nameserver/entry.go b/nameserver/entry.go index 52e901a5..3b45fd0a 100644 --- a/nameserver/entry.go +++ b/nameserver/entry.go @@ -233,8 +233,8 @@ type GossipData struct { } func (g *GossipData) Merge(o router.GossipData) { - checkAndPanic(CaseSensitive(g.Entries)) - defer func() { checkAndPanic(CaseSensitive(g.Entries)) }() + checkAndPanic(CaseInsensitive(g.Entries)) + defer func() { checkAndPanic(CaseInsensitive(g.Entries)) }() other := o.(*GossipData) g.Entries.merge(other.Entries) if g.Timestamp < other.Timestamp { @@ -243,9 +243,12 @@ func (g *GossipData) Merge(o router.GossipData) { } func (g *GossipData) Encode() [][]byte { - checkAndPanic(CaseSensitive(g.Entries)) + // Make a copy so we can sort: all outgoing data is sent in case-sensitive order + g2 := GossipData{Timestamp: g.Timestamp, Entries: make(Entries, len(g.Entries))} + copy(g2.Entries, g.Entries) + sort.Sort(CaseSensitive(g2.Entries)) buf := &bytes.Buffer{} - if err := gob.NewEncoder(buf).Encode(g); err != nil { + if err := gob.NewEncoder(buf).Encode(g2); err != nil { panic(err) } return [][]byte{buf.Bytes()} diff --git a/nameserver/nameserver.go b/nameserver/nameserver.go index 19037804..a2e9f238 100644 --- a/nameserver/nameserver.go +++ b/nameserver/nameserver.go @@ -196,7 +196,6 @@ func (n *Nameserver) Gossip() router.GossipData { Timestamp: now(), } copy(gossip.Entries, n.entries) - sort.Sort(CaseSensitive(gossip.Entries)) return gossip }