Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Hold DNS entries sorted case-insensitively until just before sending #1611

Closed
wants to merge 5 commits into from

Conversation

bboreham
Copy link
Contributor

Instead of sorting when creating the outbound GossipData object, we sort in Encode().
Fixes #1603 and #1610

checkAndPanic(CaseSensitive(g.Entries))
defer func() { checkAndPanic(CaseSensitive(g.Entries)) }()
checkAndPanic(CaseInsensitive(g.Entries))
defer func() { checkAndPanic(CaseInsensitive(g.Entries)) }()

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@rade
Copy link
Member

rade commented Oct 29, 2015

needs to be branched off 1.2

@rade
Copy link
Member

rade commented Oct 29, 2015

I reckon the gossip data decoding code should be moved near the encoding code. e.g.

func (g *GossipData) Decode(msg []byte) error {
    if err := gob.NewDecoder(bytes.NewReader(msg)).Decode(g); err != nil {
        return err
    }
    sort.Sort(CaseInsensitive(g.Entries))
    return nil
}

and then call it from Nameserver.receiveGossip like this:

    var gossip GossipData
    if err := gossip.Decode(msg); err != nil {
        return nil, nil, err
    }
    if delta := gossip.Timestamp - now(); delta > gossipWindow || delta < -gossipWindow {
        return nil, nil, fmt.Errorf("clock skew of %d detected", delta)
    }
        ...

(I think that works)

@rade
Copy link
Member

rade commented Oct 30, 2015

the unit tests failed.

@bboreham
Copy link
Contributor Author

Wrong branch; replaced by #1615

@bboreham bboreham closed this Oct 30, 2015
}}

require.Equal(t, expected, g1)
}

This comment was marked as abuse.

@rade rade added this to the 1.2.1 milestone Nov 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants