mirror of
https://github.com/SagerNet/sing-quic.git
synced 2025-04-02 03:17:38 +03:00
Update golangci-lint configuration
This commit is contained in:
parent
caa7813f48
commit
b2aa8a079f
4 changed files with 21 additions and 10 deletions
|
@ -5,6 +5,8 @@ linters:
|
|||
- govet
|
||||
- gci
|
||||
- staticcheck
|
||||
- paralleltest
|
||||
- ineffassign
|
||||
|
||||
linters-settings:
|
||||
gci:
|
||||
|
@ -14,4 +16,9 @@ linters-settings:
|
|||
- prefix(github.com/sagernet/)
|
||||
- default
|
||||
staticcheck:
|
||||
go: '1.20'
|
||||
checks:
|
||||
- all
|
||||
- -SA1003
|
||||
|
||||
run:
|
||||
go: "1.23"
|
|
@ -20,7 +20,6 @@ import (
|
|||
E "github.com/sagernet/sing/common/exceptions"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
N "github.com/sagernet/sing/common/network"
|
||||
"github.com/sagernet/sing/common/rw"
|
||||
)
|
||||
|
||||
var udpMessagePool = sync.Pool{
|
||||
|
@ -404,10 +403,12 @@ func decodeUDPMessage(message *udpMessage, data []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
message.host, err = rw.ReadString(reader, int(hostLen))
|
||||
hostBytes := make([]byte, hostLen)
|
||||
_, err = io.ReadFull(reader, hostBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
message.host = string(hostBytes)
|
||||
err = binary.Read(reader, binary.BigEndian, &message.port)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/rw"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -81,10 +80,12 @@ func ReadClientHello(reader io.Reader) (*ClientHello, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
clientHello.Auth, err = rw.ReadString(reader, int(authLen))
|
||||
authBytes := make([]byte, authLen)
|
||||
_, err = io.ReadFull(reader, authBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
clientHello.Auth = string(authBytes)
|
||||
return &clientHello, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/rw"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -107,10 +106,12 @@ func ReadTCPResponse(r io.Reader) (ok bool, message string, err error) {
|
|||
if messageLen > MaxMessageLength {
|
||||
return false, "", E.New("invalid message length")
|
||||
}
|
||||
message, err = rw.ReadString(r, int(messageLen))
|
||||
messageBytes := make([]byte, messageLen)
|
||||
_, err = io.ReadFull(r, messageBytes)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
message = string(messageBytes)
|
||||
paddingLen, err := quicvarint.Read(bReader)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -227,11 +228,12 @@ func ReadVString(reader io.Reader) (string, error) {
|
|||
if length > MaxAddressLength {
|
||||
return "", E.New("invalid address length")
|
||||
}
|
||||
value, err := rw.ReadBytes(reader, int(length))
|
||||
stringBytes := make([]byte, length)
|
||||
_, err = io.ReadFull(reader, stringBytes)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(value), nil
|
||||
return string(stringBytes), nil
|
||||
}
|
||||
|
||||
func WriteVString(writer io.Writer, value string) error {
|
||||
|
@ -239,7 +241,7 @@ func WriteVString(writer io.Writer, value string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return rw.WriteString(writer, value)
|
||||
return common.Error(writer.Write([]byte(value)))
|
||||
}
|
||||
|
||||
func WriteUVariant(writer io.Writer, value uint64) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue