From b66003746a7b4b49b6777724fed47b49df2fdaba Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Fri, 7 Jul 2017 11:58:52 +0100 Subject: [PATCH] Update gomatrixserverlib --- vendor/manifest | 2 +- .../matrix-org/gomatrixserverlib/event.go | 6 +++--- .../matrix-org/gomatrixserverlib/eventauth.go | 3 +++ .../gomatrixserverlib/federationtypes.go | 2 +- .../gomatrixserverlib/hooks/pre-commit | 17 ++++++++++++++++- .../matrix-org/gomatrixserverlib/json.go | 4 ++-- .../matrix-org/gomatrixserverlib/keys.go | 2 +- .../matrix-org/gomatrixserverlib/request.go | 2 +- .../matrix-org/gomatrixserverlib/resolve.go | 4 ++-- .../gomatrixserverlib/signing_test.go | 4 ++-- .../gomatrixserverlib/stateresolution_test.go | 12 ++++++------ .../matrix-org/gomatrixserverlib/transaction.go | 2 +- 12 files changed, 39 insertions(+), 21 deletions(-) diff --git a/vendor/manifest b/vendor/manifest index 209abd3ef..95c4b6f8b 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -98,7 +98,7 @@ { "importpath": "github.com/matrix-org/gomatrixserverlib", "repository": "https://github.com/matrix-org/gomatrixserverlib", - "revision": "0e1596ae7b0a034ec572cd1448aeaf7e96bff95a", + "revision": "30652b26ec2e83b97c941eb1c293bf7d67340f74", "branch": "master" }, { diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go index 678bf42e7..94de35189 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/event.go @@ -500,9 +500,9 @@ func (e Event) AuthEvents() []EventReference { // AuthEventIDs returns the event IDs of the events needed to auth the event. func (e Event) AuthEventIDs() []string { - result := make([]string, len(e.fields.PrevEvents)) - for i := range e.fields.PrevEvents { - result[i] = e.fields.PrevEvents[i].EventID + result := make([]string, len(e.fields.AuthEvents)) + for i := range e.fields.AuthEvents { + result[i] = e.fields.AuthEvents[i].EventID } return result } diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/eventauth.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/eventauth.go index 15c47bfc3..f9b938a32 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/eventauth.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/eventauth.go @@ -379,6 +379,9 @@ func aliasEventAllowed(event Event, authEvents AuthEventProvider) error { // https://github.com/matrix-org/synapse/blob/v0.18.5/synapse/api/auth.py#L143-L160 create, err := newCreateContentFromAuthEvents(authEvents) + if err != nil { + return err + } senderDomain, err := domainFromID(event.Sender()) if err != nil { diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go index 1f9c81eb1..1c0fff4b1 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go @@ -213,7 +213,7 @@ type respSendJoinFields struct { AuthEvents []Event `json:"auth_chain"` } -// Check that a reponse to /send_join is valid. +// Check that a response to /send_join is valid. // This checks that it would be valid as a response to /state // This also checks that the join event is allowed by the state. func (r RespSendJoin) Check(keyRing KeyRing, joinEvent Event) error { diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/hooks/pre-commit b/vendor/src/github.com/matrix-org/gomatrixserverlib/hooks/pre-commit index 6ea7d146b..a7ec4d015 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/hooks/pre-commit +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/hooks/pre-commit @@ -3,7 +3,22 @@ set -eu golint ./... -go fmt +misspell -error . + +# gofmt doesn't exit with an error code if the files don't match the expected +# format. So we have to run it and see if it outputs anything. +if gofmt -l -s . 2>&1 | read +then + echo "Error: not all code had been formatted with gofmt." + echo "Fixing the following files" + gofmt -s -w -l . + echo + echo "Please add them to the commit" + git status --short + exit 1 +fi + +ineffassign . go tool vet --all --shadow . gocyclo -over 16 . go test -timeout 5s . ./... diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/json.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/json.go index 141f365bf..e29f283d5 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/json.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/json.go @@ -23,7 +23,7 @@ import ( "unicode/utf8" ) -// CanonicalJSON re-encodes the JSON in a cannonical encoding. The encoding is +// CanonicalJSON re-encodes the JSON in a canonical encoding. The encoding is // the shortest possible encoding using integer values with sorted object keys. // https://matrix.org/docs/spec/server_server/unstable.html#canonical-json func CanonicalJSON(input []byte) ([]byte, error) { @@ -223,7 +223,7 @@ func compactUnicodeEscape(input, output []byte, index int) ([]byte, int) { // Taken from https://github.com/NegativeMjark/indolentjson-rust/blob/8b959791fe2656a88f189c5d60d153be05fe3deb/src/readhex.rs#L21 func readHexDigits(input []byte) uint32 { hex := binary.BigEndian.Uint32(input) - // substract '0' + // subtract '0' hex -= 0x30303030 // strip the higher bits, maps 'a' => 'A' hex &= 0x1F1F1F1F diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/keys.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/keys.go index ffd57e59f..5fb20c7f6 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/keys.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/keys.go @@ -167,7 +167,7 @@ type KeyChecks struct { AllEd25519ChecksOK *bool // All the Ed25519 checks are ok. or null if there weren't any to check. Ed25519Checks map[KeyID]Ed25519Checks // Checks for Ed25519 keys. HasTLSFingerprint bool // The server has at least one fingerprint. - AllTLSFingerprintChecksOK *bool // All the fingerpint checks are ok. + AllTLSFingerprintChecksOK *bool // All the fingerprint checks are ok. TLSFingerprintChecks []TLSFingerprintChecks // Checks for TLS fingerprints. MatchingTLSFingerprint *bool // The TLS fingerprint for the connection matches one of the listed fingerprints. } diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/request.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/request.go index 34ada3565..f2dc5af4c 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/request.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/request.go @@ -268,7 +268,7 @@ func readHTTPRequest(req *http.Request) (*FederationRequest, error) { } result.fields.Origin = origin if result.fields.Signatures == nil { - result.fields.Signatures = map[ServerName]map[KeyID]string{origin: map[KeyID]string{key: sig}} + result.fields.Signatures = map[ServerName]map[KeyID]string{origin: {key: sig}} } else { result.fields.Signatures[origin][key] = sig } diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/resolve.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/resolve.go index c3e1ff9e0..a2af2ed83 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/resolve.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/resolve.go @@ -57,7 +57,7 @@ func LookupServer(serverName ServerName) (*DNSResult, error) { return nil, err } // If there isn't a SRV record in DNS then fallback to "serverName:8448". - hosts[string(serverName)] = []net.SRV{net.SRV{ + hosts[string(serverName)] = []net.SRV{{ Target: string(serverName), Port: 8448, }} @@ -80,7 +80,7 @@ func LookupServer(serverName ServerName) (*DNSResult, error) { if err != nil { return nil, err } - hosts[host] = []net.SRV{net.SRV{ + hosts[host] = []net.SRV{{ Target: host, Port: uint16(port), }} diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/signing_test.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/signing_test.go index ca1f955a6..e69bf31bf 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/signing_test.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/signing_test.go @@ -179,7 +179,7 @@ func TestSignJSONTestVectors(t *testing.T) { type MyMessage struct { Unsigned *json.RawMessage `json:"unsigned"` Content *json.RawMessage `json:"content"` - Signatures *json.RawMessage `json:"signature,omitempty"` + Signatures *json.RawMessage `json:"signatures,omitempty"` } func TestSignJSONWithUnsigned(t *testing.T) { @@ -215,7 +215,7 @@ func TestSignJSONWithUnsigned(t *testing.T) { t.Fatal(err) } - err = VerifyJSON(entityName, keyID, publicKey, signed) + err = VerifyJSON(entityName, keyID, publicKey, input) if err != nil { t.Errorf("VerifyJSON(%q)", signed) t.Fatal(err) diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/stateresolution_test.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/stateresolution_test.go index 289a73783..4b04a9c5c 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/stateresolution_test.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/stateresolution_test.go @@ -12,15 +12,15 @@ const ( func TestConflictEventSorter(t *testing.T) { input := []Event{ - Event{fields: eventFields{Depth: 1, EventID: "@1:a"}}, - Event{fields: eventFields{Depth: 2, EventID: "@2:a"}}, - Event{fields: eventFields{Depth: 2, EventID: "@3:b"}}, + {fields: eventFields{Depth: 1, EventID: "@1:a"}}, + {fields: eventFields{Depth: 2, EventID: "@2:a"}}, + {fields: eventFields{Depth: 2, EventID: "@3:b"}}, } got := sortConflictedEventsByDepthAndSHA1(input) want := []conflictedEvent{ - conflictedEvent{depth: 1, event: &input[0]}, - conflictedEvent{depth: 2, event: &input[2]}, - conflictedEvent{depth: 2, event: &input[1]}, + {depth: 1, event: &input[0]}, + {depth: 2, event: &input[2]}, + {depth: 2, event: &input[1]}, } copy(want[0].eventIDSHA1[:], sha1OfEventID1A) copy(want[1].eventIDSHA1[:], sha1OfEventID3B) diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/transaction.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/transaction.go index f0e2d3f75..918c18e50 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/transaction.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/transaction.go @@ -24,7 +24,7 @@ type Transaction struct { } // A TransactionID identifies a transaction sent by a matrix server to another -// matrix server. The ID must be unique amoungst the transactions sent from the +// matrix server. The ID must be unique amongst the transactions sent from the // origin server to the destination, but doesn't have to be globally unique. // The ID must be safe to insert into a URL path segment. The ID should have a // format matching '^[0-9A-Za-z\-_]*$'