mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 23:04:02 +03:00
Upgrade golangci-lint for 1.42
This commit is contained in:
@@ -72,7 +72,7 @@ jobs:
|
|||||||
- name: Run linter
|
- name: Run linter
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
version: v1.37.1
|
version: v1.42.0
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ APP_NAME := $(IMAGE_NAME)
|
|||||||
|
|
||||||
CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
|
CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
|
||||||
|
|
||||||
GOLANGCI_LINT_VERSION := v1.37.1
|
GOLANGCI_LINT_VERSION := v1.42.0
|
||||||
|
|
||||||
VERSION_GO := $(shell go version)
|
VERSION_GO := $(shell go version)
|
||||||
VERSION_DATE := $(shell date -Ru)
|
VERSION_DATE := $(shell date -Ru)
|
||||||
|
|||||||
+30
-30
@@ -79,29 +79,29 @@ const (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Bind *net.TCPAddr `json:"bind"`
|
Bind *net.TCPAddr `json:"bind"`
|
||||||
PublicIPv4 *net.TCPAddr `json:"public_ipv4"`
|
PublicIPv4 *net.TCPAddr `json:"public_ipv4"` // nolint: tagliatelle
|
||||||
PublicIPv6 *net.TCPAddr `json:"public_ipv6"`
|
PublicIPv6 *net.TCPAddr `json:"public_ipv6"` // nolint: tagliatelle
|
||||||
StatsBind *net.TCPAddr `json:"stats_bind"`
|
StatsBind *net.TCPAddr `json:"stats_bind"` // nolint: tagliatelle
|
||||||
StatsdAddr *net.TCPAddr `json:"stats_addr"`
|
StatsdAddr *net.TCPAddr `json:"stats_addr"` // nolint: tagliatelle
|
||||||
StatsdTagsFormat *statsd.TagFormat `json:"statsd_tags_format"`
|
StatsdTagsFormat *statsd.TagFormat `json:"statsd_tags_format"` // nolint: tagliatelle
|
||||||
|
|
||||||
StatsNamespace string `json:"stats_namespace"`
|
StatsNamespace string `json:"stats_namespace"` // nolint: tagliatelle
|
||||||
CloakHost string `json:"cloak_host"`
|
CloakHost string `json:"cloak_host"` // nolint: tagliatelle
|
||||||
StatsdTags map[string]string `json:"statsd_tags"`
|
StatsdTags map[string]string `json:"statsd_tags"` // nolint: tagliatelle
|
||||||
|
|
||||||
WriteBuffer int `json:"write_buffer"`
|
WriteBuffer int `json:"write_buffer"` // nolint: tagliatelle
|
||||||
ReadBuffer int `json:"read_buffer"`
|
ReadBuffer int `json:"read_buffer"` // nolint: tagliatelle
|
||||||
CloakPort int `json:"cloak_port"`
|
CloakPort int `json:"cloak_port"` // nolint: tagliatelle
|
||||||
|
|
||||||
AntiReplayMaxSize int `json:"anti_replay_max_size"`
|
AntiReplayMaxSize int `json:"anti_replay_max_size"` // nolint: tagliatelle
|
||||||
|
|
||||||
MultiplexPerConnection int `json:"multiplex_per_connection"`
|
MultiplexPerConnection int `json:"multiplex_per_connection"` // nolint: tagliatelle
|
||||||
|
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
Verbose bool `json:"verbose"`
|
Verbose bool `json:"verbose"`
|
||||||
SecretMode SecretMode `json:"secret_mode"`
|
SecretMode SecretMode `json:"secret_mode"` // nolint: tagliatelle
|
||||||
PreferIP PreferIP `json:"prefer_ip"`
|
PreferIP PreferIP `json:"prefer_ip"` // nolint: tagliatelle
|
||||||
NTPServers []string `json:"ntp_servers"`
|
NTPServers []string `json:"ntp_servers"` // nolint: tagliatelle
|
||||||
|
|
||||||
Secret []byte `json:"secret"`
|
Secret []byte `json:"secret"`
|
||||||
AdTag []byte `json:"adtag"`
|
AdTag []byte `json:"adtag"`
|
||||||
@@ -164,11 +164,11 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
|||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
switch opt.Option {
|
switch opt.Option {
|
||||||
case OptionTypeDebug:
|
case OptionTypeDebug:
|
||||||
C.Debug = opt.Value.(bool)
|
C.Debug = opt.Value.(bool) // nolint: forcetypeassert
|
||||||
case OptionTypeVerbose:
|
case OptionTypeVerbose:
|
||||||
C.Verbose = opt.Value.(bool)
|
C.Verbose = opt.Value.(bool) // nolint: forcetypeassert
|
||||||
case OptionTypePreferIP:
|
case OptionTypePreferIP:
|
||||||
value := opt.Value.(string)
|
value := opt.Value.(string) // nolint: forcetypeassert
|
||||||
switch value {
|
switch value {
|
||||||
case "ipv4":
|
case "ipv4":
|
||||||
C.PreferIP = PreferIPv4
|
C.PreferIP = PreferIPv4
|
||||||
@@ -178,25 +178,25 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
|||||||
return fmt.Errorf("incorrect direct IP mode %s", value)
|
return fmt.Errorf("incorrect direct IP mode %s", value)
|
||||||
}
|
}
|
||||||
case OptionTypeBind:
|
case OptionTypeBind:
|
||||||
C.Bind = opt.Value.(*net.TCPAddr)
|
C.Bind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
||||||
case OptionTypePublicIPv4:
|
case OptionTypePublicIPv4:
|
||||||
C.PublicIPv4 = opt.Value.(*net.TCPAddr)
|
C.PublicIPv4 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
||||||
if C.PublicIPv4 == nil {
|
if C.PublicIPv4 == nil {
|
||||||
C.PublicIPv4 = &net.TCPAddr{}
|
C.PublicIPv4 = &net.TCPAddr{}
|
||||||
}
|
}
|
||||||
case OptionTypePublicIPv6:
|
case OptionTypePublicIPv6:
|
||||||
C.PublicIPv6 = opt.Value.(*net.TCPAddr)
|
C.PublicIPv6 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
||||||
if C.PublicIPv6 == nil {
|
if C.PublicIPv6 == nil {
|
||||||
C.PublicIPv6 = &net.TCPAddr{}
|
C.PublicIPv6 = &net.TCPAddr{}
|
||||||
}
|
}
|
||||||
case OptionTypeStatsBind:
|
case OptionTypeStatsBind:
|
||||||
C.StatsBind = opt.Value.(*net.TCPAddr)
|
C.StatsBind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
||||||
case OptionTypeStatsNamespace:
|
case OptionTypeStatsNamespace:
|
||||||
C.StatsNamespace = opt.Value.(string)
|
C.StatsNamespace = opt.Value.(string) // nolint: forcetypeassert
|
||||||
case OptionTypeStatsdAddress:
|
case OptionTypeStatsdAddress:
|
||||||
C.StatsdAddr = opt.Value.(*net.TCPAddr)
|
C.StatsdAddr = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
|
||||||
case OptionTypeStatsdTagsFormat:
|
case OptionTypeStatsdTagsFormat:
|
||||||
value := opt.Value.(string)
|
value := opt.Value.(string) // nolint: forcetypeassert
|
||||||
switch value {
|
switch value {
|
||||||
case "datadog":
|
case "datadog":
|
||||||
C.StatsdTagsFormat = statsd.TagFormatDatadog
|
C.StatsdTagsFormat = statsd.TagFormatDatadog
|
||||||
@@ -206,7 +206,7 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
|||||||
return fmt.Errorf("incorrect statsd tag %s", value)
|
return fmt.Errorf("incorrect statsd tag %s", value)
|
||||||
}
|
}
|
||||||
case OptionTypeStatsdTags:
|
case OptionTypeStatsdTags:
|
||||||
C.StatsdTags = opt.Value.(map[string]string)
|
C.StatsdTags = opt.Value.(map[string]string) // nolint: forcetypeassert
|
||||||
case OptionTypeWriteBufferSize:
|
case OptionTypeWriteBufferSize:
|
||||||
C.WriteBuffer = int(opt.Value.(units.Base2Bytes))
|
C.WriteBuffer = int(opt.Value.(units.Base2Bytes))
|
||||||
case OptionTypeReadBufferSize:
|
case OptionTypeReadBufferSize:
|
||||||
@@ -218,14 +218,14 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
|
|||||||
case OptionTypeMultiplexPerConnection:
|
case OptionTypeMultiplexPerConnection:
|
||||||
C.MultiplexPerConnection = int(opt.Value.(uint))
|
C.MultiplexPerConnection = int(opt.Value.(uint))
|
||||||
case OptionTypeNTPServers:
|
case OptionTypeNTPServers:
|
||||||
C.NTPServers = opt.Value.([]string)
|
C.NTPServers = opt.Value.([]string) // nolint: forcetypeassert
|
||||||
if len(C.NTPServers) == 0 {
|
if len(C.NTPServers) == 0 {
|
||||||
return errors.New("ntp server list is empty")
|
return errors.New("ntp server list is empty")
|
||||||
}
|
}
|
||||||
case OptionTypeSecret:
|
case OptionTypeSecret:
|
||||||
C.Secret = opt.Value.([]byte)
|
C.Secret = opt.Value.([]byte) // nolint: forcetypeassert
|
||||||
case OptionTypeAdtag:
|
case OptionTypeAdtag:
|
||||||
C.AdTag = opt.Value.([]byte)
|
C.AdTag = opt.Value.([]byte) // nolint: forcetypeassert
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown tag %v", opt.Option)
|
return fmt.Errorf("unknown tag %v", opt.Option)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
|
|||||||
Timeout: ifconfigTimeout,
|
Timeout: ifconfigTimeout,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
|
||||||
return dialer.DialContext(ctx, network, addr)
|
return dialer.DialContext(ctx, network, addr) // nolint: wrapcheck
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -8,16 +8,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type URLs struct {
|
type URLs struct {
|
||||||
TG string `json:"tg_url"`
|
TG string `json:"tg_url"` // nolint: tagliatelle
|
||||||
TMe string `json:"tme_url"`
|
TMe string `json:"tme_url"` // nolint: tagliatelle
|
||||||
TGQRCode string `json:"tg_qrcode"`
|
TGQRCode string `json:"tg_qrcode"` // nolint: tagliatelle
|
||||||
TMeQRCode string `json:"tme_qrcode"`
|
TMeQRCode string `json:"tme_qrcode"` // nolint: tagliatelle
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPURLs struct {
|
type IPURLs struct {
|
||||||
IPv4 *URLs `json:"ipv4,omitempty"`
|
IPv4 *URLs `json:"ipv4,omitempty"`
|
||||||
IPv6 *URLs `json:"ipv6,omitempty"`
|
IPv6 *URLs `json:"ipv6,omitempty"`
|
||||||
BotSecret string `json:"secret_for_mtproxybot"`
|
BotSecret string `json:"secret_for_mtproxybot"` // nolint: tagliatelle
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetURLs() (urls IPURLs) {
|
func GetURLs() (urls IPURLs) {
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ func (h *hub) Register(req *protocol.TelegramRequest) (*ProxyConn, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *hub) getMux(req *protocol.TelegramRequest) *mux {
|
func (h *hub) getMux(req *protocol.TelegramRequest) *mux {
|
||||||
var key int32 = 32767 + int32(req.ClientProtocol.DC()) + 100000*int32(req.ClientProtocol.ConnectionProtocol())
|
key := 32767 + int32(req.ClientProtocol.DC()) + 100000*int32(req.ClientProtocol.ConnectionProtocol())
|
||||||
|
|
||||||
h.mutex.RLock()
|
h.mutex.RLock()
|
||||||
m, ok := h.muxes[key]
|
m, ok := h.muxes[key]
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
|
|||||||
}
|
}
|
||||||
|
|
||||||
decHasher := sha256.New()
|
decHasher := sha256.New()
|
||||||
decHasher.Write(fm.Key()) // nolint: errcheck
|
decHasher.Write(fm.Key())
|
||||||
decHasher.Write(config.C.Secret) // nolint: errcheck
|
decHasher.Write(config.C.Secret)
|
||||||
decryptor := utils.MakeStreamCipher(decHasher.Sum(nil), fm.IV())
|
decryptor := utils.MakeStreamCipher(decHasher.Sum(nil), fm.IV())
|
||||||
|
|
||||||
invertedFrame := fm.Invert()
|
invertedFrame := fm.Invert()
|
||||||
encHasher := sha256.New()
|
encHasher := sha256.New()
|
||||||
encHasher.Write(invertedFrame.Key()) // nolint: errcheck
|
encHasher.Write(invertedFrame.Key())
|
||||||
encHasher.Write(config.C.Secret) // nolint: errcheck
|
encHasher.Write(config.C.Secret)
|
||||||
encryptor := utils.MakeStreamCipher(encHasher.Sum(nil), invertedFrame.IV())
|
encryptor := utils.MakeStreamCipher(encHasher.Sum(nil), invertedFrame.IV())
|
||||||
|
|
||||||
decryptedFrame := Frame{}
|
decryptedFrame := Frame{}
|
||||||
@@ -106,7 +106,7 @@ type handshakeReader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h handshakeReader) Read(p []byte) (int, error) {
|
func (h handshakeReader) Read(p []byte) (int, error) {
|
||||||
return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout)
|
return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeClientProtocol() protocol.ClientProtocol {
|
func MakeClientProtocol() protocol.ClientProtocol {
|
||||||
|
|||||||
+3
-6
@@ -4,7 +4,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/conntypes"
|
|
||||||
"github.com/9seconds/mtg/obfuscated2"
|
"github.com/9seconds/mtg/obfuscated2"
|
||||||
"github.com/9seconds/mtg/protocol"
|
"github.com/9seconds/mtg/protocol"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@@ -18,16 +17,14 @@ func directConnection(request *protocol.TelegramRequest) error {
|
|||||||
return err // nolint: wrapcheck
|
return err // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
telegramConn := telegramConnRaw.(conntypes.StreamReadWriteCloser)
|
defer telegramConnRaw.Close()
|
||||||
|
|
||||||
defer telegramConn.Close()
|
|
||||||
|
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
|
|
||||||
go directPipe(telegramConn, request.ClientConn, wg, request.Logger)
|
go directPipe(telegramConnRaw, request.ClientConn, wg, request.Logger)
|
||||||
|
|
||||||
go directPipe(request.ClientConn, telegramConn, wg, request.Logger)
|
go directPipe(request.ClientConn, telegramConnRaw, wg, request.Logger)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ func (s ServerHello) WelcomePacket() []byte {
|
|||||||
packet := buf.Bytes()
|
packet := buf.Bytes()
|
||||||
|
|
||||||
mac := hmac.New(sha256.New, config.C.Secret)
|
mac := hmac.New(sha256.New, config.C.Secret)
|
||||||
mac.Write(s.clientHello.Random[:]) // nolint: errcheck
|
mac.Write(s.clientHello.Random[:])
|
||||||
mac.Write(packet) // nolint: errcheck
|
mac.Write(packet)
|
||||||
copy(packet[11:], mac.Sum(nil))
|
copy(packet[11:], mac.Sum(nil))
|
||||||
|
|
||||||
return packet
|
return packet
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
||||||
tcpConn := conn.(*net.TCPConn)
|
tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
|
||||||
|
|
||||||
if err := tcpConn.SetNoDelay(true); err != nil {
|
if err := tcpConn.SetNoDelay(true); err != nil {
|
||||||
return fmt.Errorf("cannot set TCP_NO_DELAY: %w", err)
|
return fmt.Errorf("cannot set TCP_NO_DELAY: %w", err)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//go:build !windows
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//go:build !windows
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ func (w *wrapperMtprotoFrame) Write(p conntypes.Packet) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperMtprotoFrame) Close() error {
|
func (w *wrapperMtprotoFrame) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperMtprotoFrame) Conn() net.Conn {
|
func (w *wrapperMtprotoFrame) Conn() net.Conn {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func (w *wrapperClientAbridged) Write(packet conntypes.Packet, acks *conntypes.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientAbridged) Close() error {
|
func (w *wrapperClientAbridged) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientAbridged) Conn() net.Conn {
|
func (w *wrapperClientAbridged) Conn() net.Conn {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ func (w *wrapperClientIntermediate) Write(packet conntypes.Packet, acks *conntyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientIntermediate) Close() error {
|
func (w *wrapperClientIntermediate) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperClientIntermediate) Conn() net.Conn {
|
func (w *wrapperClientIntermediate) Conn() net.Conn {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (w *wrapperProxy) Write(packet conntypes.Packet, acks *conntypes.Connection
|
|||||||
buf.Grow(len(packet))
|
buf.Grow(len(packet))
|
||||||
buf.Write(packet)
|
buf.Write(packet)
|
||||||
|
|
||||||
return w.proxy.Write(buf.Bytes())
|
return w.proxy.Write(buf.Bytes()) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
|
func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (w *wrapperPing) Write(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperPing) Close() error {
|
func (w *wrapperPing) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {
|
func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (w *wrapperBlockCipher) Write(p []byte) (int, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.parent.Write(encrypted)
|
return w.parent.Write(encrypted) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
@@ -35,7 +35,7 @@ func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int,
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.parent.WriteTimeout(encrypted, timeout)
|
return w.parent.WriteTimeout(encrypted, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
|
func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
|
||||||
@@ -50,7 +50,7 @@ func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) Close() error {
|
func (w *wrapperBlockCipher) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperBlockCipher) Conn() net.Conn {
|
func (w *wrapperBlockCipher) Conn() net.Conn {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func (b *bufferedReader) ReadTimeout(p []byte, _ time.Duration) (int, error) {
|
|||||||
|
|
||||||
func (b *bufferedReader) flush(p []byte) (int, error) {
|
func (b *bufferedReader) flush(p []byte) (int, error) {
|
||||||
if b.buf.Len() > len(p) {
|
if b.buf.Len() > len(p) {
|
||||||
return b.buf.Read(p)
|
return b.buf.Read(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeToReturn := b.buf.Len()
|
sizeToReturn := b.buf.Len()
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func (w *wrapperConn) Read(p []byte) (int, error) {
|
|||||||
func (w *wrapperConn) Close() error {
|
func (w *wrapperConn) Close() error {
|
||||||
w.logger.Debugw("Close connection")
|
w.logger.Debugw("Close connection")
|
||||||
|
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperConn) Conn() net.Conn {
|
func (w *wrapperConn) Conn() net.Conn {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (w *wrapperCtx) WriteTimeout(p []byte, timeout time.Duration) (int, error)
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.WriteTimeout(p, timeout)
|
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ func (w *wrapperCtx) Write(p []byte) (int, error) {
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.Write(p)
|
return w.parent.Write(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ func (w *wrapperCtx) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.ReadTimeout(p, timeout)
|
return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +56,14 @@ func (w *wrapperCtx) Read(p []byte) (int, error) {
|
|||||||
|
|
||||||
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
|
||||||
default:
|
default:
|
||||||
return w.parent.Read(p)
|
return w.parent.Read(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperCtx) Close() error {
|
func (w *wrapperCtx) Close() error {
|
||||||
w.cancel()
|
w.cancel()
|
||||||
|
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperCtx) Conn() net.Conn {
|
func (w *wrapperCtx) Conn() net.Conn {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type wrapperFakeTLS struct {
|
|||||||
|
|
||||||
func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
|
func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
|
||||||
return w.write(p, func(b []byte) (int, error) {
|
return w.write(p, func(b []byte) (int, error) {
|
||||||
return w.parent.Write(b)
|
return w.parent.Write(b) // nolint: wrapcheck
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func (w *wrapperFakeTLS) WriteTimeout(p []byte, timeout time.Duration) (int, err
|
|||||||
return w.write(p, func(b []byte) (int, error) {
|
return w.write(p, func(b []byte) (int, error) {
|
||||||
elapsed := time.Since(startTime)
|
elapsed := time.Since(startTime)
|
||||||
if elapsed > timeout {
|
if elapsed > timeout {
|
||||||
return w.parent.WriteTimeout(b, timeout-elapsed)
|
return w.parent.WriteTimeout(b, timeout-elapsed) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, errors.New("timeout")
|
return 0, errors.New("timeout")
|
||||||
@@ -73,7 +73,7 @@ func (w *wrapperFakeTLS) RemoteAddr() *net.TCPAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperFakeTLS) Close() error {
|
func (w *wrapperFakeTLS) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (w *wrapperObfuscated2) WriteTimeout(p []byte, timeout time.Duration) (int,
|
|||||||
|
|
||||||
w.encryptor.XORKeyStream(buf, buf)
|
w.encryptor.XORKeyStream(buf, buf)
|
||||||
|
|
||||||
return w.parent.WriteTimeout(buf, timeout)
|
return w.parent.WriteTimeout(buf, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
|
func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
|
||||||
@@ -60,7 +60,7 @@ func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
|
|||||||
|
|
||||||
w.encryptor.XORKeyStream(buf, buf)
|
w.encryptor.XORKeyStream(buf, buf)
|
||||||
|
|
||||||
return w.parent.Write(buf)
|
return w.parent.Write(buf) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperObfuscated2) Conn() net.Conn {
|
func (w *wrapperObfuscated2) Conn() net.Conn {
|
||||||
@@ -80,7 +80,7 @@ func (w *wrapperObfuscated2) RemoteAddr() *net.TCPAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperObfuscated2) Close() error {
|
func (w *wrapperObfuscated2) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
|
func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
|
||||||
|
|||||||
@@ -24,25 +24,25 @@ type wrapperRewind struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Write(p []byte) (int, error) {
|
func (w *wrapperRewind) Write(p []byte) (int, error) {
|
||||||
return w.parent.Write(p)
|
return w.parent.Write(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperRewind) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeout)
|
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Read(p []byte) (int, error) {
|
func (w *wrapperRewind) Read(p []byte) (int, error) {
|
||||||
w.mutex.Lock()
|
w.mutex.Lock()
|
||||||
defer w.mutex.Unlock()
|
defer w.mutex.Unlock()
|
||||||
|
|
||||||
return w.activeReader.Read(p)
|
return w.activeReader.Read(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) ReadTimeout(p []byte, _ time.Duration) (int, error) {
|
func (w *wrapperRewind) ReadTimeout(p []byte, _ time.Duration) (int, error) {
|
||||||
w.mutex.Lock()
|
w.mutex.Lock()
|
||||||
defer w.mutex.Unlock()
|
defer w.mutex.Unlock()
|
||||||
|
|
||||||
return w.activeReader.Read(p)
|
return w.activeReader.Read(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Conn() net.Conn {
|
func (w *wrapperRewind) Conn() net.Conn {
|
||||||
@@ -64,7 +64,7 @@ func (w *wrapperRewind) RemoteAddr() *net.TCPAddr {
|
|||||||
func (w *wrapperRewind) Close() error {
|
func (w *wrapperRewind) Close() error {
|
||||||
w.buf.Reset()
|
w.buf.Reset()
|
||||||
|
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperRewind) Rewind() {
|
func (w *wrapperRewind) Rewind() {
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ type wrapperTelegramStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
|
func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
|
||||||
return w.parent.Write(p)
|
return w.parent.Write(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeout)
|
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
|
func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
|
||||||
return w.parent.Read(p)
|
return w.parent.Read(p) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.ReadTimeout(p, timeout)
|
return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTelegramStats) Conn() net.Conn {
|
func (w *wrapperTelegramStats) Conn() net.Conn {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func (w *wrapperTrafficStats) RemoteAddr() *net.TCPAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTrafficStats) Close() error {
|
func (w *wrapperTrafficStats) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
|
||||||
|
|||||||
@@ -18,23 +18,23 @@ type wrapperTimeout struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTimeout) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeout)
|
return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Write(p []byte) (int, error) {
|
func (w *wrapperTimeout) Write(p []byte) (int, error) {
|
||||||
return w.parent.WriteTimeout(p, timeoutWrite)
|
return w.parent.WriteTimeout(p, timeoutWrite) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
func (w *wrapperTimeout) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
|
||||||
return w.parent.ReadTimeout(p, timeout)
|
return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Read(p []byte) (int, error) {
|
func (w *wrapperTimeout) Read(p []byte) (int, error) {
|
||||||
return w.parent.ReadTimeout(p, timeoutRead)
|
return w.parent.ReadTimeout(p, timeoutRead) // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Close() error {
|
func (w *wrapperTimeout) Close() error {
|
||||||
return w.parent.Close()
|
return w.parent.Close() // nolint: wrapcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapperTimeout) Conn() net.Conn {
|
func (w *wrapperTimeout) Conn() net.Conn {
|
||||||
|
|||||||
Reference in New Issue
Block a user