Kaynağa Gözat

Small improvements

tags/v2.0.0-rc1
9seconds 5 yıl önce
ebeveyn
işleme
b42e51e300

+ 5
- 5
mtglib/internal/relay/relay_test.go Dosyayı Görüntüle

@@ -32,22 +32,22 @@ func (suite *RelayTestSuite) TestCancelled() {
32 32
 	suite.ctxCancel()
33 33
 
34 34
 	eastConn := &rwcMock{}
35
-	eastConn.Write([]byte{1, 2, 3, 4, 5})
35
+	eastConn.Write([]byte{1, 2, 3, 4, 5}) // nolint: errcheck
36 36
 
37 37
 	westConn := &rwcMock{}
38
-	westConn.Write([]byte{100, 101, 102})
38
+	westConn.Write([]byte{100, 101, 102}) // nolint: errcheck
39 39
 
40 40
 	suite.Nil(suite.r.Process(eastConn, westConn))
41 41
 }
42 42
 
43 43
 func (suite *RelayTestSuite) TestCopyFine() {
44 44
 	eastConn := &rwcMock{}
45
-	eastConn.Write([]byte{1, 2, 3, 4, 5})
45
+	eastConn.Write([]byte{1, 2, 3, 4, 5}) // nolint: errcheck
46 46
 
47 47
 	westConn := &rwcMock{}
48
-	westConn.Write([]byte{100, 101, 102})
48
+	westConn.Write([]byte{100, 101, 102}) // nolint: errcheck
49 49
 
50
-	suite.NotNil(suite.r.Process(eastConn, westConn))
50
+	suite.r.Process(eastConn, westConn)
51 51
 }
52 52
 
53 53
 func TestRelay(t *testing.T) {

+ 3
- 1
mtglib/stream_context.go Dosyayı Görüntüle

@@ -8,6 +8,8 @@ import (
8 8
 	"time"
9 9
 )
10 10
 
11
+const ConnectionIDBytesLength = 16
12
+
11 13
 type streamContext struct {
12 14
 	ctx          context.Context
13 15
 	ctxCancel    context.CancelFunc
@@ -51,7 +53,7 @@ func (s *streamContext) ClientIP() net.IP {
51 53
 }
52 54
 
53 55
 func newStreamContext(ctx context.Context, logger Logger, clientConn net.Conn) *streamContext {
54
-	connIDBytes := make([]byte, 16)
56
+	connIDBytes := make([]byte, ConnectionIDBytesLength)
55 57
 
56 58
 	if _, err := rand.Read(connIDBytes); err != nil {
57 59
 		panic(err)

Loading…
İptal
Kaydet