Skip to content

Commit

Permalink
Fix linter configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Dec 29, 2024
1 parent 4d92911 commit 065e3b0
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ linters-settings:

run:
go: "1.23"
build-tags:
- with_gvisor
- with_quic
- with_dhcp
- with_wireguard
- with_ech
- with_utls
- with_reality_server
- with_acme
- with_clash_api

issues:
exclude-dirs:
Expand Down
2 changes: 1 addition & 1 deletion cmd/sing-box/cmd_tools_fetch_http3.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func initializeHTTP3Client(instance *box.Box) error {
return err
}
http3Client = &http.Client{
Transport: &http3.RoundTripper{
Transport: &http3.Transport{
Dial: func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
destination := M.ParseSocksaddr(addr)
udpConn, dErr := dialer.DialContext(ctx, N.NetworkUDP, destination)
Expand Down
1 change: 1 addition & 0 deletions common/tls/ech_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type echConnWrapper struct {

func (c *echConnWrapper) ConnectionState() tls.ConnectionState {
state := c.Conn.ConnectionState()
//nolint:staticcheck
return tls.ConnectionState{
Version: state.Version,
HandshakeComplete: state.HandshakeComplete,
Expand Down
3 changes: 3 additions & 0 deletions common/tls/ech_keygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func echKeygen(version uint16, serverName string, conf []myECHKeyConfig, suite [
pair.rawConf = b

secBuf, err := sec.MarshalBinary()
if err != nil {
return nil, E.Cause(err, "serialize ECH private key")
}
sk := []byte{}
sk = be.AppendUint16(sk, uint16(len(secBuf)))
sk = append(sk, secBuf...)
Expand Down
2 changes: 1 addition & 1 deletion common/tls/ech_quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *echClientConfig) DialEarly(ctx context.Context, conn net.PacketConn, ad
}

func (c *echClientConfig) CreateTransport(conn net.PacketConn, quicConnPtr *quic.EarlyConnection, serverAddr M.Socksaddr, quicConfig *quic.Config) http.RoundTripper {
return &http3.RoundTripper{
return &http3.Transport{
TLSClientConfig: c.config,
QUICConfig: quicConfig,
Dial: func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
Expand Down
1 change: 1 addition & 0 deletions common/tls/reality_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ type realityConnWrapper struct {

func (c *realityConnWrapper) ConnectionState() ConnectionState {
state := c.Conn.ConnectionState()
//nolint:staticcheck
return tls.ConnectionState{
Version: state.Version,
HandshakeComplete: state.HandshakeComplete,
Expand Down
1 change: 1 addition & 0 deletions common/tls/utls_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type utlsConnWrapper struct {

func (c *utlsConnWrapper) ConnectionState() tls.ConnectionState {
state := c.Conn.ConnectionState()
//nolint:staticcheck
return tls.ConnectionState{
Version: state.Version,
HandshakeComplete: state.HandshakeComplete,
Expand Down
4 changes: 2 additions & 2 deletions inbound/hysteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func NewHysteria(ctx context.Context, router adapter.Router, logger log.ContextL
}
if len(options.Down) > 0 {
receiveBps, err = humanize.ParseBytes(options.Down)
if receiveBps == 0 {
return nil, E.New("invalid down speed format: ", options.Down)
if err != nil {
return nil, E.Cause(err, "invalid down speed format: ", options.Down)
}
} else {
receiveBps = uint64(options.DownMbps) * hysteria.MbpsToBps
Expand Down
4 changes: 2 additions & 2 deletions outbound/hysteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func NewHysteria(ctx context.Context, router adapter.Router, logger log.ContextL
}
if len(options.Down) > 0 {
receiveBps, err = humanize.ParseBytes(options.Down)
if receiveBps == 0 {
return nil, E.New("invalid down speed format: ", options.Down)
if err != nil {
return nil, E.Cause(err, "invalid down speed format: ", options.Down)
}
} else {
receiveBps = uint64(options.DownMbps) * hysteria.MbpsToBps
Expand Down

0 comments on commit 065e3b0

Please sign in to comment.