fix: resolve golangci-lint warnings

Добавлена проверка ошибки listener.SetDeadline в tcputil.
Удален вызов устаревшего метода SetStreamMode в KCP.
Добавлено явное игнорирование возвращаемых значений SetDeadline и io.Copy .
This commit is contained in:
Moroka8 committed 2026-04-04 15:56:21 +07:00
1 parent 4a0b038bdc
commit 7abbd4986f
3 files changed
+15 -14

No files matched your search

+6 -6
View File
@@ -1760,8 +1760,8 @@ func (r *relayPacketConn) SetWriteDeadline(t time.Time) error { return r.relay.S
func pipe(ctx context.Context, c1, c2 net.Conn) { func pipe(ctx context.Context, c1, c2 net.Conn) {
ctx2, cancel := context.WithCancel(ctx) ctx2, cancel := context.WithCancel(ctx)
context.AfterFunc(ctx2, func() { context.AfterFunc(ctx2, func() {
c1.SetDeadline(time.Now()) _ = c1.SetDeadline(time.Now())
c2.SetDeadline(time.Now()) _ = c2.SetDeadline(time.Now())
}) })
var wg sync.WaitGroup var wg sync.WaitGroup
@@ -1769,14 +1769,14 @@ func pipe(ctx context.Context, c1, c2 net.Conn) {
go func() { go func() {
defer wg.Done() defer wg.Done()
defer cancel() defer cancel()
io.Copy(c1, c2) _, _ = io.Copy(c1, c2)
}() }()
go func() { go func() {
defer wg.Done() defer wg.Done()
defer cancel() defer cancel()
io.Copy(c2, c1) _, _ = io.Copy(c2, c1)
}() }()
wg.Wait() wg.Wait()
c1.SetDeadline(time.Time{}) _ = c1.SetDeadline(time.Time{})
c2.SetDeadline(time.Time{}) _ = c2.SetDeadline(time.Time{})
} }
+6 -6
View File
@@ -270,8 +270,8 @@ func handleTCPConnection(ctx context.Context, dtlsConn net.Conn, connectAddr str
func pipeConn(ctx context.Context, c1, c2 net.Conn) { func pipeConn(ctx context.Context, c1, c2 net.Conn) {
ctx2, cancel := context.WithCancel(ctx) ctx2, cancel := context.WithCancel(ctx)
context.AfterFunc(ctx2, func() { context.AfterFunc(ctx2, func() {
c1.SetDeadline(time.Now()) _ = c1.SetDeadline(time.Now())
c2.SetDeadline(time.Now()) _ = c2.SetDeadline(time.Now())
}) })
var wg sync.WaitGroup var wg sync.WaitGroup
@@ -279,14 +279,14 @@ func pipeConn(ctx context.Context, c1, c2 net.Conn) {
go func() { go func() {
defer wg.Done() defer wg.Done()
defer cancel() defer cancel()
io.Copy(c1, c2) _, _ = io.Copy(c1, c2)
}() }()
go func() { go func() {
defer wg.Done() defer wg.Done()
defer cancel() defer cancel()
io.Copy(c2, c1) _, _ = io.Copy(c2, c1)
}() }()
wg.Wait() wg.Wait()
c1.SetDeadline(time.Time{}) _ = c1.SetDeadline(time.Time{})
c2.SetDeadline(time.Time{}) _ = c2.SetDeadline(time.Time{})
} }
+3 -2
View File
@@ -63,7 +63,9 @@ func NewKCPOverDTLS(dtlsConn net.Conn, isServer bool) (*kcp.UDPSession, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.SetDeadline(time.Now().Add(30 * time.Second)) if err = listener.SetDeadline(time.Now().Add(30 * time.Second)); err != nil {
return nil, err
}
sess, err = listener.AcceptKCP() sess, err = listener.AcceptKCP()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -83,7 +85,6 @@ func NewKCPOverDTLS(dtlsConn net.Conn, isServer bool) (*kcp.UDPSession, error) {
sess.SetWindowSize(256, 256) sess.SetWindowSize(256, 256)
sess.SetMtu(1200) // conservative MTU to fit inside DTLS+TURN sess.SetMtu(1200) // conservative MTU to fit inside DTLS+TURN
sess.SetACKNoDelay(true) sess.SetACKNoDelay(true)
sess.SetStreamMode(true)
return sess, nil return sess, nil
} }