From 00ca2be6a5bfd108e2f25318fe4a179a63344a71 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 22 Sep 2021 10:52:01 -0400 Subject: [PATCH] Run gofmt --- appservice/registration.go | 2 +- appservice/txnid.go | 2 +- crypto/attachment/attachments_test.go | 1 + crypto/keyexport.go | 4 ++++ crypto/keysharing.go | 1 + crypto/olm/inboundgroupsession.go | 2 +- crypto/olm/session.go | 2 +- crypto/olm/verification.go | 1 + crypto/sql_store.go | 2 +- crypto/ssss/key_test.go | 2 +- crypto/unwedge.go | 2 +- crypto/verification.go | 1 + crypto/verification_in_room.go | 2 +- crypto/verification_sas_methods.go | 1 + event/accountdata.go | 2 +- id/contenturi.go | 2 +- id/matrixuri_test.go | 10 +++++----- pushrules/condition_eventmatch_test.go | 4 ++-- pushrules/pushrules_test.go | 2 +- 19 files changed, 27 insertions(+), 18 deletions(-) diff --git a/appservice/registration.go b/appservice/registration.go index 87557746..382522f5 100644 --- a/appservice/registration.go +++ b/appservice/registration.go @@ -21,7 +21,7 @@ type Registration struct { AppToken string `yaml:"as_token"` ServerToken string `yaml:"hs_token"` SenderLocalpart string `yaml:"sender_localpart"` - RateLimited *bool `yaml:"rate_limited,omitempty"` + RateLimited *bool `yaml:"rate_limited,omitempty"` Namespaces Namespaces `yaml:"namespaces"` EphemeralEvents bool `yaml:"de.sorunome.msc2409.push_ephemeral,omitempty"` Protocols []string `yaml:"protocols,omitempty"` diff --git a/appservice/txnid.go b/appservice/txnid.go index bce93d2e..213703c5 100644 --- a/appservice/txnid.go +++ b/appservice/txnid.go @@ -40,4 +40,4 @@ func (txnIDC *TransactionIDCache) MarkProcessed(txnID string) { } txnIDC.array[txnIDC.arrayPtr] = txnID txnIDC.lock.Unlock() -} \ No newline at end of file +} diff --git a/crypto/attachment/attachments_test.go b/crypto/attachment/attachments_test.go index 1b8e69ac..64ce84a9 100644 --- a/crypto/attachment/attachments_test.go +++ b/crypto/attachment/attachments_test.go @@ -25,6 +25,7 @@ const helloWorldRawFile = `{ } }` const random16Bytes = "\x85\xb4\x16/\xcaO\x1d\xe6\x7f\x95\xeb\xdb+g\x11\xb1" + var random16BytesBase64 = base64.StdEncoding.EncodeToString([]byte(random16Bytes)) func parseHelloWorld() *EncryptedFile { diff --git a/crypto/keyexport.go b/crypto/keyexport.go index 511a56dd..c1a2f029 100644 --- a/crypto/keyexport.go +++ b/crypto/keyexport.go @@ -45,12 +45,16 @@ const defaultPassphraseRounds = 100000 const exportPrefix = "-----BEGIN MEGOLM SESSION DATA-----\n" const exportSuffix = "-----END MEGOLM SESSION DATA-----\n" + // Only version 0x01 is currently specified in the spec const exportVersion1 = 0x01 + // The standard for wrapping base64 is 76 bytes const exportLineLengthLimit = 76 + // Byte count for version + salt + iv + number of rounds const exportHeaderLength = 1 + 16 + 16 + 4 + // SHA-256 hash length const exportHashLength = 32 diff --git a/crypto/keysharing.go b/crypto/keysharing.go index f514a4af..5390204c 100644 --- a/crypto/keysharing.go +++ b/crypto/keysharing.go @@ -4,6 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +//go:build !nosas // +build !nosas package crypto diff --git a/crypto/olm/inboundgroupsession.go b/crypto/olm/inboundgroupsession.go index 4dda6346..793703a6 100644 --- a/crypto/olm/inboundgroupsession.go +++ b/crypto/olm/inboundgroupsession.go @@ -164,7 +164,7 @@ func (s *InboundGroupSession) GobDecode(rawPickled []byte) error { func (s *InboundGroupSession) MarshalJSON() ([]byte, error) { pickled := s.Pickle(pickleKey) - quotes := make([]byte, len(pickled) + 2) + quotes := make([]byte, len(pickled)+2) quotes[0] = '"' quotes[len(quotes)-1] = '"' copy(quotes[1:len(quotes)-1], pickled) diff --git a/crypto/olm/session.go b/crypto/olm/session.go index 337f56ce..e7062c48 100644 --- a/crypto/olm/session.go +++ b/crypto/olm/session.go @@ -164,7 +164,7 @@ func (s *Session) GobDecode(rawPickled []byte) error { func (s *Session) MarshalJSON() ([]byte, error) { pickled := s.Pickle(pickleKey) - quotes := make([]byte, len(pickled) + 2) + quotes := make([]byte, len(pickled)+2) quotes[0] = '"' quotes[len(quotes)-1] = '"' copy(quotes[1:len(quotes)-1], pickled) diff --git a/crypto/olm/verification.go b/crypto/olm/verification.go index b36904d3..119e5659 100644 --- a/crypto/olm/verification.go +++ b/crypto/olm/verification.go @@ -1,3 +1,4 @@ +//go:build !nosas // +build !nosas package olm diff --git a/crypto/sql_store.go b/crypto/sql_store.go index 716a44b1..57a7899f 100644 --- a/crypto/sql_store.go +++ b/crypto/sql_store.go @@ -32,7 +32,7 @@ type SQLCryptoStore struct { PickleKey []byte Account *OlmAccount - olmSessionCache map[id.SenderKey]map[id.SessionID]*OlmSession + olmSessionCache map[id.SenderKey]map[id.SessionID]*OlmSession olmSessionCacheLock sync.Mutex } diff --git a/crypto/ssss/key_test.go b/crypto/ssss/key_test.go index c2747e93..5fd879db 100644 --- a/crypto/ssss/key_test.go +++ b/crypto/ssss/key_test.go @@ -86,4 +86,4 @@ func TestKey_Encrypt(t *testing.T) { decrypted, err := key1.Decrypt(evtType, encrypted) assert.NoError(t, err) assert.Equal(t, data, decrypted) -} \ No newline at end of file +} diff --git a/crypto/unwedge.go b/crypto/unwedge.go index fbe3a7a6..a78da0a7 100644 --- a/crypto/unwedge.go +++ b/crypto/unwedge.go @@ -18,4 +18,4 @@ func (mach *OlmMachine) markDeviceForUnwedging(sender id.UserID, senderKey id.Se func (mach *OlmMachine) checkIfWedged(evt *event.Event) { //content := evt.Content.AsEncrypted() // TODO implement -} \ No newline at end of file +} diff --git a/crypto/verification.go b/crypto/verification.go index c2fe26ec..10a4afbe 100644 --- a/crypto/verification.go +++ b/crypto/verification.go @@ -4,6 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +//go:build !nosas // +build !nosas package crypto diff --git a/crypto/verification_in_room.go b/crypto/verification_in_room.go index fe7c5c3f..c1cf0bf1 100644 --- a/crypto/verification_in_room.go +++ b/crypto/verification_in_room.go @@ -20,7 +20,7 @@ import ( var ( ErrNoVerificationFromDevice = errors.New("from_device field is empty") ErrNoVerificationMethods = errors.New("verification method list is empty") - ErrNoRelatesTo = errors.New("missing m.relates_to info") + ErrNoRelatesTo = errors.New("missing m.relates_to info") ) // ProcessInRoomVerification is a callback that is to be called when a client receives a message diff --git a/crypto/verification_sas_methods.go b/crypto/verification_sas_methods.go index 659ce86c..a983e246 100644 --- a/crypto/verification_sas_methods.go +++ b/crypto/verification_sas_methods.go @@ -4,6 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +//go:build !nosas // +build !nosas package crypto diff --git a/event/accountdata.go b/event/accountdata.go index 32932337..7883e678 100644 --- a/event/accountdata.go +++ b/event/accountdata.go @@ -42,4 +42,4 @@ type IgnoredUserListEventContent struct { type IgnoredUser struct { // This is an empty object -} \ No newline at end of file +} diff --git a/id/contenturi.go b/id/contenturi.go index 967bba9a..0a6c1555 100644 --- a/id/contenturi.go +++ b/id/contenturi.go @@ -86,7 +86,7 @@ func (uri *ContentURI) UnmarshalJSON(raw []byte) (err error) { } else if len(raw) < 2 || raw[0] != '"' || raw[len(raw)-1] != '"' { return InputNotJSONString } - parsed, err := ParseContentURIBytes(raw[1:len(raw)-1]) + parsed, err := ParseContentURIBytes(raw[1 : len(raw)-1]) if err != nil { return err } diff --git a/id/matrixuri_test.go b/id/matrixuri_test.go index 5b9d91e8..4e4096c0 100644 --- a/id/matrixuri_test.go +++ b/id/matrixuri_test.go @@ -16,12 +16,12 @@ import ( ) var ( - roomIDLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org"} - roomIDViaLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Via: []string{"maunium.net", "matrix.org"}} - roomAliasLink = id.MatrixURI{Sigil1: '#', MXID1: "someroom:example.org"} - roomIDEventLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Sigil2: '$', MXID2: "uOH4C9cK4HhMeFWkUXMbdF_dtndJ0j9je-kIK3XpV1s"} + roomIDLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org"} + roomIDViaLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Via: []string{"maunium.net", "matrix.org"}} + roomAliasLink = id.MatrixURI{Sigil1: '#', MXID1: "someroom:example.org"} + roomIDEventLink = id.MatrixURI{Sigil1: '!', MXID1: "7NdBVvkd4aLSbgKt9RXl:example.org", Sigil2: '$', MXID2: "uOH4C9cK4HhMeFWkUXMbdF_dtndJ0j9je-kIK3XpV1s"} roomAliasEventLink = id.MatrixURI{Sigil1: '#', MXID1: "someroom:example.org", Sigil2: '$', MXID2: "uOH4C9cK4HhMeFWkUXMbdF_dtndJ0j9je-kIK3XpV1s"} - userLink = id.MatrixURI{Sigil1: '@', MXID1: "user:example.org"} + userLink = id.MatrixURI{Sigil1: '@', MXID1: "user:example.org"} ) func TestMatrixURI_MatrixToURL(t *testing.T) { diff --git a/pushrules/condition_eventmatch_test.go b/pushrules/condition_eventmatch_test.go index 90317ed0..82bb6b54 100644 --- a/pushrules/condition_eventmatch_test.go +++ b/pushrules/condition_eventmatch_test.go @@ -18,7 +18,7 @@ func TestPushCondition_Match_KindEvent_MsgType(t *testing.T) { condition := newMatchPushCondition("content.msgtype", "m.emote") evt := newFakeEvent(event.EventMessage, &event.MessageEventContent{ MsgType: event.MsgEmote, - Body: "tests gomuks pushconditions", + Body: "tests gomuks pushconditions", }) assert.True(t, condition.Match(blankTestRoom, evt)) } @@ -28,7 +28,7 @@ func TestPushCondition_Match_KindEvent_MsgType_Fail(t *testing.T) { evt := newFakeEvent(event.EventMessage, &event.MessageEventContent{ MsgType: event.MsgText, - Body: "I'm testing gomuks pushconditions", + Body: "I'm testing gomuks pushconditions", }) assert.False(t, condition.Match(blankTestRoom, evt)) } diff --git a/pushrules/pushrules_test.go b/pushrules/pushrules_test.go index 158a29bd..a531ca28 100644 --- a/pushrules/pushrules_test.go +++ b/pushrules/pushrules_test.go @@ -20,7 +20,7 @@ func TestEventToPushRules(t *testing.T) { evt := &event.Event{ Type: event.AccountDataPushRules, Timestamp: 1523380910, - Content: event.Content{ + Content: event.Content{ VeryRaw: json.RawMessage(JSONExamplePushRules), }, }