Skip to content

Commit b8c2ab4

Browse files
committed
Fix lint issues with golangci-lint@v2
1 parent 0bf1902 commit b8c2ab4

File tree

14 files changed

+109
-113
lines changed

14 files changed

+109
-113
lines changed

cipher_suite.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,40 @@ type CipherSuiteID = ciphersuite.ID
2323
// Supported Cipher Suites.
2424
const (
2525
// AES-128-CCM
26-
//nolint:revive,stylecheck
26+
//nolint:staticcheck
2727
TLS_ECDHE_ECDSA_WITH_AES_128_CCM CipherSuiteID = ciphersuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM
28-
//nolint:revive,stylecheck
28+
//nolint:staticcheck
2929
TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 CipherSuiteID = ciphersuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
3030

3131
// AES-128-GCM-SHA256
32-
//nolint:revive,stylecheck
32+
//nolint:staticcheck
3333
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 CipherSuiteID = ciphersuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
34-
//nolint:revive,stylecheck
34+
//nolint:staticcheck
3535
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 CipherSuiteID = ciphersuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
3636

37-
//nolint:revive,stylecheck
37+
//nolint:staticcheck
3838
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 CipherSuiteID = ciphersuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
39-
//nolint:revive,stylecheck
39+
//nolint:staticcheck
4040
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 CipherSuiteID = ciphersuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
4141

4242
// AES-256-CBC-SHA
43-
//nolint:revive,stylecheck
43+
//nolint:staticcheck
4444
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA CipherSuiteID = ciphersuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
45-
//nolint:revive,stylecheck
45+
//nolint:staticcheck
4646
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA CipherSuiteID = ciphersuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
4747

48-
//nolint:revive,stylecheck
48+
//nolint:staticcheck
4949
TLS_PSK_WITH_AES_128_CCM CipherSuiteID = ciphersuite.TLS_PSK_WITH_AES_128_CCM
50-
//nolint:revive,stylecheck
50+
//nolint:staticcheck
5151
TLS_PSK_WITH_AES_128_CCM_8 CipherSuiteID = ciphersuite.TLS_PSK_WITH_AES_128_CCM_8
52-
//nolint:revive,stylecheck
52+
//nolint:staticcheck
5353
TLS_PSK_WITH_AES_256_CCM_8 CipherSuiteID = ciphersuite.TLS_PSK_WITH_AES_256_CCM_8
54-
//nolint:revive,stylecheck
54+
//nolint:staticcheck
5555
TLS_PSK_WITH_AES_128_GCM_SHA256 CipherSuiteID = ciphersuite.TLS_PSK_WITH_AES_128_GCM_SHA256
56-
//nolint:revive,stylecheck
56+
//nolint:staticcheck
5757
TLS_PSK_WITH_AES_128_CBC_SHA256 CipherSuiteID = ciphersuite.TLS_PSK_WITH_AES_128_CBC_SHA256
5858

59-
//nolint:revive,stylecheck
59+
//nolint:staticcheck
6060
TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 CipherSuiteID = ciphersuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
6161
)
6262

conn_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ func TestPSK(t *testing.T) {
578578
conf := &Config{
579579
PSK: func(hint []byte) ([]byte, error) {
580580
if !bytes.Equal(test.ServerIdentity, hint) {
581-
return nil, fmt.Errorf( //nolint:goerr113
581+
return nil, fmt.Errorf( //nolint:err113
582582
"TestPSK: Client got invalid identity expected(% 02x) actual(% 02x)",
583583
test.ServerIdentity, hint,
584584
)
@@ -1800,14 +1800,14 @@ func TestPSKConfiguration(t *testing.T) { //nolint:cyclop
18001800
test.ServerHasCertificate,
18011801
)
18021802
if err != nil || test.WantServerError != nil {
1803-
if !(err != nil && test.WantServerError != nil && err.Error() == test.WantServerError.Error()) {
1803+
if err == nil || test.WantServerError == nil || err.Error() != test.WantServerError.Error() {
18041804
assert.Failf(t, "TestPSKConfiguration", "Server Error Mismatch '%s'", test.Name)
18051805
}
18061806
}
18071807

18081808
res := <-resultCh
18091809
if res.err != nil || test.WantClientError != nil {
1810-
if !(res.err != nil && test.WantClientError != nil && res.err.Error() == test.WantClientError.Error()) {
1810+
if res.err == nil || test.WantClientError == nil && res.err.Error() != test.WantClientError.Error() {
18111811
assert.Failf(t, "TestPSKConfiguration", "Client Error Mismatch '%s'", test.Name)
18121812
}
18131813
}

e2e/e2e_lossy_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ func TestPionE2ELossy(t *testing.T) { //nolint:cyclop
193193
}
194194
}()
195195

196-
for {
197-
if serverConn != nil && clientConn != nil {
198-
break
199-
}
200-
196+
for serverConn == nil || clientConn == nil {
201197
br.Tick()
202198
select {
203199
case serverResult := <-serverDone:

errors.go

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,122 +17,122 @@ import (
1717

1818
// Typed errors.
1919
var (
20-
ErrConnClosed = &FatalError{Err: errors.New("conn is closed")} //nolint:goerr113
20+
ErrConnClosed = &FatalError{Err: errors.New("conn is closed")} //nolint:err113
2121

2222
errDeadlineExceeded = &TimeoutError{Err: fmt.Errorf("read/write timeout: %w", context.DeadlineExceeded)}
23-
errInvalidContentType = &TemporaryError{Err: errors.New("invalid content type")} //nolint:goerr113
23+
errInvalidContentType = &TemporaryError{Err: errors.New("invalid content type")} //nolint:err113
2424

25-
//nolint:goerr113
25+
//nolint:err113
2626
errBufferTooSmall = &TemporaryError{Err: errors.New("buffer is too small")}
27-
//nolint:goerr113
27+
//nolint:err113
2828
errContextUnsupported = &TemporaryError{Err: errors.New("context is not supported for ExportKeyingMaterial")}
29-
//nolint:goerr113
29+
//nolint:err113
3030
errHandshakeInProgress = &TemporaryError{Err: errors.New("handshake is in progress")}
31-
//nolint:goerr113
31+
//nolint:err113
3232
errReservedExportKeyingMaterial = &TemporaryError{
3333
Err: errors.New("ExportKeyingMaterial can not be used with a reserved label"),
3434
}
35-
//nolint:goerr113
35+
//nolint:err113
3636
errApplicationDataEpochZero = &TemporaryError{Err: errors.New("ApplicationData with epoch of 0")}
37-
//nolint:goerr113
37+
//nolint:err113
3838
errUnhandledContextType = &TemporaryError{Err: errors.New("unhandled contentType")}
3939

40-
//nolint:goerr113
40+
//nolint:err113
4141
errCertificateVerifyNoCertificate = &FatalError{
4242
Err: errors.New("client sent certificate verify but we have no certificate to verify"),
4343
}
44-
//nolint:goerr113
44+
//nolint:err113
4545
errCipherSuiteNoIntersection = &FatalError{Err: errors.New("client+server do not support any shared cipher suites")}
46-
//nolint:goerr113
46+
//nolint:err113
4747
errClientCertificateNotVerified = &FatalError{Err: errors.New("client sent certificate but did not verify it")}
48-
//nolint:goerr113
48+
//nolint:err113
4949
errClientCertificateRequired = &FatalError{Err: errors.New("server required client verification, but got none")}
50-
//nolint:goerr113
50+
//nolint:err113
5151
errClientNoMatchingSRTPProfile = &FatalError{Err: errors.New("server responded with SRTP Profile we do not support")}
52-
//nolint:goerr113
52+
//nolint:err113
5353
errClientRequiredButNoServerEMS = &FatalError{
5454
Err: errors.New("client required Extended Master Secret extension, but server does not support it"),
5555
}
56-
//nolint:goerr113
56+
//nolint:err113
5757
errCookieMismatch = &FatalError{Err: errors.New("client+server cookie does not match")}
58-
//nolint:goerr113
58+
//nolint:err113
5959
errIdentityNoPSK = &FatalError{Err: errors.New("PSK Identity Hint provided but PSK is nil")}
60-
//nolint:goerr113
60+
//nolint:err113
6161
errInvalidCertificate = &FatalError{Err: errors.New("no certificate provided")}
62-
//nolint:goerr113
62+
//nolint:err113
6363
errInvalidCipherSuite = &FatalError{Err: errors.New("invalid or unknown cipher suite")}
64-
//nolint:goerr113
64+
//nolint:err113
6565
errInvalidECDSASignature = &FatalError{Err: errors.New("ECDSA signature contained zero or negative values")}
66-
//nolint:goerr113
66+
//nolint:err113
6767
errInvalidPrivateKey = &FatalError{Err: errors.New("invalid private key type")}
68-
//nolint:goerr113
68+
//nolint:err113
6969
errInvalidSignatureAlgorithm = &FatalError{Err: errors.New("invalid signature algorithm")}
70-
//nolint:goerr113
70+
//nolint:err113
7171
errKeySignatureMismatch = &FatalError{Err: errors.New("expected and actual key signature do not match")}
72-
//nolint:goerr113
72+
//nolint:err113
7373
errNilNextConn = &FatalError{Err: errors.New("Conn can not be created with a nil nextConn")}
74-
//nolint:goerr113
74+
//nolint:err113
7575
errNoAvailableCipherSuites = &FatalError{
7676
Err: errors.New("connection can not be created, no CipherSuites satisfy this Config"),
7777
}
78-
//nolint:goerr113
78+
//nolint:err113
7979
errNoAvailablePSKCipherSuite = &FatalError{
8080
Err: errors.New("connection can not be created, pre-shared key present but no compatible CipherSuite"),
8181
}
82-
//nolint:goerr113
82+
//nolint:err113
8383
errNoAvailableCertificateCipherSuite = &FatalError{
8484
Err: errors.New("connection can not be created, certificate present but no compatible CipherSuite"),
8585
}
86-
//nolint:goerr113
86+
//nolint:err113
8787
errNoAvailableSignatureSchemes = &FatalError{
8888
Err: errors.New("connection can not be created, no SignatureScheme satisfy this Config"),
8989
}
90-
//nolint:goerr113
90+
//nolint:err113
9191
errNoCertificates = &FatalError{Err: errors.New("no certificates configured")}
92-
//nolint:goerr113
92+
//nolint:err113
9393
errNoConfigProvided = &FatalError{Err: errors.New("no config provided")}
94-
//nolint:goerr113
94+
//nolint:err113
9595
errNoSupportedEllipticCurves = &FatalError{
9696
Err: errors.New("client requested zero or more elliptic curves that are not supported by the server"),
9797
}
98-
//nolint:goerr113
98+
//nolint:err113
9999
errUnsupportedProtocolVersion = &FatalError{Err: errors.New("unsupported protocol version")}
100-
//nolint:goerr113
100+
//nolint:err113
101101
errPSKAndIdentityMustBeSetForClient = &FatalError{
102102
Err: errors.New("PSK and PSK Identity Hint must both be set for client"),
103103
}
104-
//nolint:goerr113
104+
//nolint:err113
105105
errRequestedButNoSRTPExtension = &FatalError{
106106
Err: errors.New("SRTP support was requested but server did not respond with use_srtp extension"),
107107
}
108-
//nolint:goerr113
108+
//nolint:err113
109109
errServerNoMatchingSRTPProfile = &FatalError{Err: errors.New("client requested SRTP but we have no matching profiles")}
110-
//nolint:goerr113
110+
//nolint:err113
111111
errServerRequiredButNoClientEMS = &FatalError{
112112
Err: errors.New("server requires the Extended Master Secret extension, but the client does not support it"),
113113
}
114-
//nolint:goerr113
114+
//nolint:err113
115115
errVerifyDataMismatch = &FatalError{Err: errors.New("expected and actual verify data does not match")}
116-
//nolint:goerr113
116+
//nolint:err113
117117
errNotAcceptableCertificateChain = &FatalError{Err: errors.New("certificate chain is not signed by an acceptable CA")}
118118

119-
//nolint:goerr113
119+
//nolint:err113
120120
errInvalidFlight = &InternalError{Err: errors.New("invalid flight number")}
121-
//nolint:goerr113
121+
//nolint:err113
122122
errKeySignatureGenerateUnimplemented = &InternalError{
123123
Err: errors.New("unable to generate key signature, unimplemented"),
124124
}
125-
//nolint:goerr113
125+
//nolint:err113
126126
errKeySignatureVerifyUnimplemented = &InternalError{Err: errors.New("unable to verify key signature, unimplemented")}
127-
//nolint:goerr113
127+
//nolint:err113
128128
errLengthMismatch = &InternalError{Err: errors.New("data length and declared length do not match")}
129-
//nolint:goerr113
129+
//nolint:err113
130130
errSequenceNumberOverflow = &InternalError{Err: errors.New("sequence number overflow")}
131-
//nolint:goerr113
131+
//nolint:err113
132132
errInvalidFSMTransition = &InternalError{Err: errors.New("invalid state machine transition")}
133-
//nolint:goerr113
133+
//nolint:err113
134134
errFailedToAccessPoolReadBuffer = &InternalError{Err: errors.New("failed to access pool read buffer")}
135-
//nolint:goerr113
135+
//nolint:err113
136136
errFragmentBufferOverflow = &InternalError{Err: errors.New("fragment buffer overflow")}
137137
)
138138

handshaker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (c *handshakeConfig) writeKeyLog(label string, clientRandom, secret []byte)
152152
}
153153
c.mu.Lock()
154154
defer c.mu.Unlock()
155-
_, err := c.keyLogWriter.Write([]byte(fmt.Sprintf("%s %x %x\n", label, clientRandom, secret)))
155+
_, err := fmt.Fprintf(c.keyLogWriter, "%s %x %x\n", label, clientRandom, secret)
156156
if err != nil {
157157
c.log.Debugf("failed to write key log file: %s", err)
158158
}

internal/ciphersuite/ciphersuite.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/pion/dtls/v3/pkg/protocol"
1414
)
1515

16-
//nolint:goerr113
16+
//nolint:err113
1717
var errCipherSuiteNotInit = &protocol.TemporaryError{Err: errors.New("CipherSuite has not been initialized")}
1818

1919
// ID is an ID for our supported CipherSuites.
@@ -57,26 +57,26 @@ func (i ID) String() string { //nolint:cyclop
5757
// Supported Cipher Suites.
5858
const (
5959
// AES-128-CCM.
60-
TLS_ECDHE_ECDSA_WITH_AES_128_CCM ID = 0xc0ac //nolint:revive,stylecheck
61-
TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 ID = 0xc0ae //nolint:revive,stylecheck
60+
TLS_ECDHE_ECDSA_WITH_AES_128_CCM ID = 0xc0ac //nolint:staticcheck
61+
TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 ID = 0xc0ae //nolint:staticcheck
6262

6363
// AES-128-GCM-SHA256.
64-
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 ID = 0xc02b //nolint:revive,stylecheck
65-
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ID = 0xc02f //nolint:revive,stylecheck
64+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 ID = 0xc02b //nolint:staticcheck
65+
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ID = 0xc02f //nolint:staticcheck
6666

67-
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 ID = 0xc02c //nolint:revive,stylecheck
68-
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ID = 0xc030 //nolint:revive,stylecheck
67+
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 ID = 0xc02c //nolint:staticcheck
68+
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ID = 0xc030 //nolint:staticcheck
6969
// AES-256-CBC-SHA.
70-
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA ID = 0xc00a //nolint:revive,stylecheck
71-
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA ID = 0xc014 //nolint:revive,stylecheck
70+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA ID = 0xc00a //nolint:staticcheck
71+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA ID = 0xc014 //nolint:staticcheck
7272

73-
TLS_PSK_WITH_AES_128_CCM ID = 0xc0a4 //nolint:revive,stylecheck
74-
TLS_PSK_WITH_AES_128_CCM_8 ID = 0xc0a8 //nolint:revive,stylecheck
75-
TLS_PSK_WITH_AES_256_CCM_8 ID = 0xc0a9 //nolint:revive,stylecheck
76-
TLS_PSK_WITH_AES_128_GCM_SHA256 ID = 0x00a8 //nolint:revive,stylecheck
77-
TLS_PSK_WITH_AES_128_CBC_SHA256 ID = 0x00ae //nolint:revive,stylecheck
73+
TLS_PSK_WITH_AES_128_CCM ID = 0xc0a4 //nolint:staticcheck
74+
TLS_PSK_WITH_AES_128_CCM_8 ID = 0xc0a8 //nolint:staticcheck
75+
TLS_PSK_WITH_AES_256_CCM_8 ID = 0xc0a9 //nolint:staticcheck
76+
TLS_PSK_WITH_AES_128_GCM_SHA256 ID = 0x00a8 //nolint:staticcheck
77+
TLS_PSK_WITH_AES_128_CBC_SHA256 ID = 0x00ae //nolint:staticcheck
7878

79-
TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 ID = 0xC037 //nolint:revive,stylecheck
79+
TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 ID = 0xC037 //nolint:staticcheck
8080
)
8181

8282
// AuthenticationType controls what authentication method is using during the handshake.

pkg/crypto/ciphersuite/ciphersuite.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ const (
2121
)
2222

2323
var (
24-
//nolint:goerr113
24+
//nolint:err113
2525
errNotEnoughRoomForNonce = &protocol.InternalError{Err: errors.New("buffer not long enough to contain nonce")}
26-
//nolint:goerr113
26+
//nolint:err113
2727
errDecryptPacket = &protocol.TemporaryError{Err: errors.New("failed to decrypt packet")}
28-
//nolint:goerr113
28+
//nolint:err113
2929
errInvalidMAC = &protocol.TemporaryError{Err: errors.New("invalid mac")}
30-
//nolint:goerr113
30+
//nolint:err113
3131
errFailedToCast = &protocol.FatalError{Err: errors.New("failed to cast")}
3232
)
3333

pkg/crypto/prf/prf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type EncryptionKeys struct {
4040
ServerWriteIV []byte
4141
}
4242

43-
var errInvalidNamedCurve = &protocol.FatalError{Err: errors.New("invalid named curve")} //nolint:goerr113
43+
var errInvalidNamedCurve = &protocol.FatalError{Err: errors.New("invalid named curve")} //nolint:err113
4444

4545
func (e *EncryptionKeys) String() string {
4646
return fmt.Sprintf(`encryptionKeys:

pkg/protocol/alert/alert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/pion/dtls/v3/pkg/protocol"
1212
)
1313

14-
var errBufferTooSmall = &protocol.TemporaryError{Err: errors.New("buffer is too small")} //nolint:goerr113
14+
var errBufferTooSmall = &protocol.TemporaryError{Err: errors.New("buffer is too small")} //nolint:err113
1515

1616
// Level is the level of the TLS Alert.
1717
type Level byte

pkg/protocol/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
)
1111

1212
var (
13-
errBufferTooSmall = &TemporaryError{Err: errors.New("buffer is too small")} //nolint:goerr113
14-
errInvalidCipherSpec = &FatalError{Err: errors.New("cipher spec invalid")} //nolint:goerr113
13+
errBufferTooSmall = &TemporaryError{Err: errors.New("buffer is too small")} //nolint:err113
14+
errInvalidCipherSpec = &FatalError{Err: errors.New("cipher spec invalid")} //nolint:err113
1515
)
1616

1717
// FatalError indicates that the DTLS connection is no longer available.

0 commit comments

Comments
 (0)