Browse Source

Chore: fix lint according to golangci-lint errors (#781)

* Chore: fix lint according to golangci-lint errors
* Chore: regenerate pb.go files
Loyalsoldier 4 years ago
parent
commit
e46204f828

+ 9 - 11
app/dispatcher/default.go

@@ -305,19 +305,17 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
 			common.Interrupt(link.Reader)
 			return
 		}
-	} else {
-		if d.router != nil {
-			if route, err := d.router.PickRoute(routing_session.AsRoutingContext(ctx)); err == nil {
-				tag := route.GetOutboundTag()
-				if h := d.ohm.GetHandler(tag); h != nil {
-					newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
-					handler = h
-				} else {
-					newError("non existing tag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
-				}
+	} else if d.router != nil {
+		if route, err := d.router.PickRoute(routing_session.AsRoutingContext(ctx)); err == nil {
+			tag := route.GetOutboundTag()
+			if h := d.ohm.GetHandler(tag); h != nil {
+				newError("taking detour [", tag, "] for [", destination, "]").WriteToLog(session.ExportIDToError(ctx))
+				handler = h
 			} else {
-				newError("default route for ", destination).WriteToLog(session.ExportIDToError(ctx))
+				newError("non existing tag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))
 			}
+		} else {
+			newError("default route for ", destination).WriteToLog(session.ExportIDToError(ctx))
 		}
 	}
 

+ 1 - 1
app/reverse/bridge.go

@@ -6,7 +6,7 @@ import (
 	"context"
 	"time"
 
-	"github.com/golang/protobuf/proto"
+	"google.golang.org/protobuf/proto"
 
 	"github.com/v2fly/v2ray-core/v4/common/mux"
 	"github.com/v2fly/v2ray-core/v4/common/net"

+ 0 - 1
app/router/config.go

@@ -86,7 +86,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
 			}
 			conds.Add(matcher)
 		}
-
 	}
 
 	if len(rr.UserEmail) > 0 {

+ 4 - 4
common/mux/client.go

@@ -135,11 +135,11 @@ type DialingWorkerFactory struct {
 	ctx context.Context
 }
 
-func NewDialingWorkerFactory(ctx context.Context, Proxy proxy.Outbound, Dialer internet.Dialer, Strategy ClientStrategy) *DialingWorkerFactory {
+func NewDialingWorkerFactory(ctx context.Context, proxy proxy.Outbound, dialer internet.Dialer, strategy ClientStrategy) *DialingWorkerFactory {
 	return &DialingWorkerFactory{
-		Proxy:    Proxy,
-		Dialer:   Dialer,
-		Strategy: Strategy,
+		Proxy:    proxy,
+		Dialer:   dialer,
+		Strategy: strategy,
 		ctx:      ctx,
 	}
 }

+ 1 - 1
config.go

@@ -6,7 +6,7 @@ import (
 	"io"
 	"strings"
 
-	"github.com/golang/protobuf/proto"
+	"google.golang.org/protobuf/proto"
 
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common/buf"

+ 1 - 1
functions_test.go

@@ -7,8 +7,8 @@ import (
 	"testing"
 	"time"
 
-	"github.com/golang/protobuf/proto"
 	"github.com/google/go-cmp/cmp"
+	"google.golang.org/protobuf/proto"
 
 	core "github.com/v2fly/v2ray-core/v4"
 	"github.com/v2fly/v2ray-core/v4/app/dispatcher"

+ 1 - 0
main/distro/all/all.go

@@ -23,6 +23,7 @@ import (
 	_ "github.com/v2fly/v2ray-core/v4/app/router"
 	_ "github.com/v2fly/v2ray-core/v4/app/stats"
 
+	// Fix dependency cycle caused by core import in internet package
 	_ "github.com/v2fly/v2ray-core/v4/transport/internet/tagged/taggedimpl"
 
 	// Inbound and outbound proxies.

+ 1 - 2
proxy/vmess/encoding/server.go

@@ -198,9 +198,8 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
 		}
 		if s.isAEADForced {
 			return nil, drainConnection(newError("invalid user: VMessAEAD is enforced and a non VMessAEAD connection is received. You can still disable this security feature with environment variable v2ray.vmess.aead.forced = false . You will not be able to enable legacy header workaround in the future."))
-		} else {
-			newError("Critical Warning: potentially invalid user: a non VMessAEAD connection is received. From 2022 Jan 1st, this kind of connection will be rejected by default. You should update or replace your client software now. ").AtWarning().WriteToLog()
 		}
+		newError("Critical Warning: potentially invalid user: a non VMessAEAD connection is received. From 2022 Jan 1st, this kind of connection will be rejected by default. You should update or replace your client software now. ").AtWarning().WriteToLog()
 		user = userLegacy
 		iv := hashTimestamp(md5.New(), timestamp)
 		vmessAccount = userLegacy.Account.(*vmess.MemoryAccount)

+ 1 - 1
transport/internet/grpc/config.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
 // 	protoc-gen-go v1.25.0
-// 	protoc        v3.13.0
+// 	protoc        v3.15.5
 // source: transport/internet/grpc/config.proto
 
 package grpc

+ 1 - 1
transport/internet/grpc/encoding/stream.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
 // 	protoc-gen-go v1.25.0
-// 	protoc        v3.13.0
+// 	protoc        v3.15.5
 // source: transport/internet/grpc/encoding/stream.proto
 
 package encoding