diff --git a/linter-fast.json b/linter-fast.json index 2abb30af..fce445f2 100644 --- a/linter-fast.json +++ b/linter-fast.json @@ -10,6 +10,7 @@ "ineffassign", "gas", "misspell", - "errcheck" + "errcheck", + "vet" ] } diff --git a/linter.json b/linter.json index 649e6a0e..f8da9778 100644 --- a/linter.json +++ b/linter.json @@ -15,6 +15,7 @@ "gas", "misspell", "unparam", - "errcheck" + "errcheck", + "vet" ] } diff --git a/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go b/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go index 7d5d318d..99ba2ebd 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go +++ b/src/github.com/matrix-org/dendrite/clientapi/writers/createroom.go @@ -163,12 +163,12 @@ func createRoom(req *http.Request, device *authtypes.Device, {"m.room.member", userID, membershipContent}, {"m.room.power_levels", "", common.InitialPowerLevelsContent(userID)}, // TODO: m.room.canonical_alias - {"m.room.join_rules", "", common.JoinRulesContent{"public"}}, // FIXME: Allow this to be changed - {"m.room.history_visibility", "", common.HistoryVisibilityContent{"joined"}}, // FIXME: Allow this to be changed - {"m.room.guest_access", "", common.GuestAccessContent{"can_join"}}, // FIXME: Allow this to be changed + {"m.room.join_rules", "", common.JoinRulesContent{JoinRule: "public"}}, // FIXME: Allow this to be changed + {"m.room.history_visibility", "", common.HistoryVisibilityContent{HistoryVisibility: "joined"}}, // FIXME: Allow this to be changed + {"m.room.guest_access", "", common.GuestAccessContent{GuestAccess: "can_join"}}, // FIXME: Allow this to be changed // TODO: Other initial state items - {"m.room.name", "", common.NameContent{r.Name}}, // FIXME: Only send the name event if a name is supplied, to avoid sending a false room name removal event - {"m.room.topic", "", common.TopicContent{r.Topic}}, + {"m.room.name", "", common.NameContent{Name: r.Name}}, // FIXME: Only send the name event if a name is supplied, to avoid sending a false room name removal event + {"m.room.topic", "", common.TopicContent{Topic: r.Topic}}, // TODO: invite events // TODO: 3pid invite events // TODO: m.room.aliases diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server/main.go index 151a7a9f..b287ea62 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server/main.go @@ -67,7 +67,7 @@ func main() { keyRing := gomatrixserverlib.KeyRing{ KeyFetchers: []gomatrixserverlib.KeyFetcher{ // TODO: Use perspective key fetchers for production. - &gomatrixserverlib.DirectKeyFetcher{federation.Client}, + &gomatrixserverlib.DirectKeyFetcher{Client: federation.Client}, }, KeyDatabase: keyDB, } diff --git a/src/github.com/matrix-org/dendrite/common/config/config.go b/src/github.com/matrix-org/dendrite/common/config/config.go index 86234b8d..019774b4 100644 --- a/src/github.com/matrix-org/dendrite/common/config/config.go +++ b/src/github.com/matrix-org/dendrite/common/config/config.go @@ -413,7 +413,7 @@ func fingerprintPEM(data []byte) *gomatrixserverlib.TLSFingerprint { } if certDERBlock.Type == "CERTIFICATE" { digest := sha256.Sum256(certDERBlock.Bytes) - return &gomatrixserverlib.TLSFingerprint{digest[:]} + return &gomatrixserverlib.TLSFingerprint{SHA256: digest[:]} } } } diff --git a/src/github.com/matrix-org/dendrite/common/keydb/server_key_table.go b/src/github.com/matrix-org/dendrite/common/keydb/server_key_table.go index a459bd8c..b1d6d65f 100644 --- a/src/github.com/matrix-org/dendrite/common/keydb/server_key_table.go +++ b/src/github.com/matrix-org/dendrite/common/keydb/server_key_table.go @@ -97,7 +97,8 @@ func (s *serverKeyStatements) bulkSelectServerKeys( return nil, err } r := gomatrixserverlib.PublicKeyRequest{ - gomatrixserverlib.ServerName(serverName), gomatrixserverlib.KeyID(keyID), + ServerName: gomatrixserverlib.ServerName(serverName), + KeyID: gomatrixserverlib.KeyID(keyID), } results[r] = serverKeys } diff --git a/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go b/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go index fcca201e..b28bdec9 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go +++ b/src/github.com/matrix-org/dendrite/federationapi/readers/keys.go @@ -44,7 +44,7 @@ func localKeys(cfg config.Dendrite, validUntil time.Time) (*gomatrixserverlib.Se keys.VerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.VerifyKey{ cfg.Matrix.KeyID: { - gomatrixserverlib.Base64String(publicKey), + Key: gomatrixserverlib.Base64String(publicKey), }, } diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/authevents_test.go b/src/github.com/matrix-org/dendrite/roomserver/input/authevents_test.go index 3e4d194b..0621a084 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/authevents_test.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/authevents_test.go @@ -15,24 +15,29 @@ package input import ( - "github.com/matrix-org/dendrite/roomserver/types" "testing" + + "github.com/matrix-org/dendrite/roomserver/types" ) func benchmarkStateEntryMapLookup(entries, lookups int64, b *testing.B) { var list []types.StateEntry for i := int64(0); i < entries; i++ { - list = append(list, types.StateEntry{types.StateKeyTuple{ - types.EventTypeNID(i), - types.EventStateKeyNID(i), - }, types.EventNID(i)}) + list = append(list, types.StateEntry{ + StateKeyTuple: types.StateKeyTuple{ + EventTypeNID: types.EventTypeNID(i), + EventStateKeyNID: types.EventStateKeyNID(i), + }, + EventNID: types.EventNID(i), + }) } for i := 0; i < b.N; i++ { entryMap := stateEntryMap(list) for j := int64(0); j < lookups; j++ { entryMap.lookup(types.StateKeyTuple{ - types.EventTypeNID(j), types.EventStateKeyNID(j), + EventTypeNID: types.EventTypeNID(j), + EventStateKeyNID: types.EventStateKeyNID(j), }) } } @@ -56,9 +61,9 @@ func BenchmarkStateEntryMap1000Lookup10000(b *testing.B) { func TestStateEntryMap(t *testing.T) { entryMap := stateEntryMap([]types.StateEntry{ - {types.StateKeyTuple{1, 1}, 1}, - {types.StateKeyTuple{1, 3}, 2}, - {types.StateKeyTuple{2, 1}, 3}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 3}, EventNID: 2}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 2, EventStateKeyNID: 1}, EventNID: 3}, }) testCases := []struct { @@ -78,7 +83,7 @@ func TestStateEntryMap(t *testing.T) { } for _, testCase := range testCases { - keyTuple := types.StateKeyTuple{testCase.inputTypeNID, testCase.inputStateKey} + keyTuple := types.StateKeyTuple{EventTypeNID: testCase.inputTypeNID, EventStateKeyNID: testCase.inputStateKey} gotEventNID, gotOK := entryMap.lookup(keyTuple) if testCase.wantOK != gotOK { t.Fatalf("stateEntryMap lookup(%v): want ok to be %v, got %v", keyTuple, testCase.wantOK, gotOK) diff --git a/src/github.com/matrix-org/dendrite/roomserver/state/state_test.go b/src/github.com/matrix-org/dendrite/roomserver/state/state_test.go index 78d29f78..67af1867 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/state/state_test.go +++ b/src/github.com/matrix-org/dendrite/roomserver/state/state_test.go @@ -15,8 +15,9 @@ package state import ( - "github.com/matrix-org/dendrite/roomserver/types" "testing" + + "github.com/matrix-org/dendrite/roomserver/types" ) func TestFindDuplicateStateKeys(t *testing.T) { @@ -25,18 +26,18 @@ func TestFindDuplicateStateKeys(t *testing.T) { Want []types.StateEntry }{{ Input: []types.StateEntry{ - {types.StateKeyTuple{1, 1}, 1}, - {types.StateKeyTuple{1, 1}, 2}, - {types.StateKeyTuple{2, 2}, 3}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 2}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 2, EventStateKeyNID: 2}, EventNID: 3}, }, Want: []types.StateEntry{ - {types.StateKeyTuple{1, 1}, 1}, - {types.StateKeyTuple{1, 1}, 2}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 2}, }, }, { Input: []types.StateEntry{ - {types.StateKeyTuple{1, 1}, 1}, - {types.StateKeyTuple{1, 2}, 2}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1}, + {StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 2}, EventNID: 2}, }, Want: nil, }}