Lint: fix lint (#1427)

* Lint: replace golint with revive
* Lint: fix lint
This commit is contained in:
Loyalsoldier 2021-11-27 17:16:41 +08:00 committed by GitHub
parent 43447aa2e4
commit dce8764fd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 346 additions and 368 deletions

View File

@ -7,7 +7,7 @@ issues:
new: true
exclude-rules:
- linters:
- staticcheck
- staticcheck
text: "SA1019:"
linters:
@ -19,13 +19,13 @@ linters:
- gofmt
- gofumpt
- goimports
- golint
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- rowserrcheck
- staticcheck
- structcheck

View File

@ -117,7 +117,7 @@ func init() {
Service: nil,
}
for _, v := range simplifiedConfig.Name {
pack, err := v5cfg.LoadHeterogeneousConfigFromRawJson(ctx, "grpcservice", v, []byte("{}"))
pack, err := v5cfg.LoadHeterogeneousConfigFromRawJSON(ctx, "grpcservice", v, []byte("{}"))
if err != nil {
return nil, err
}

View File

@ -315,8 +315,8 @@ func init() {
return New(ctx, config.(*Config))
}))
common.Must(common.RegisterConfig((*SimplifiedConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
ctx = cfgcommon.NewConfigureLoadingContext(context.Background())
common.Must(common.RegisterConfig((*SimplifiedConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { // nolint: staticcheck
ctx = cfgcommon.NewConfigureLoadingContext(context.Background()) // nolint: staticcheck
geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {
return "standard"

View File

@ -11,7 +11,7 @@ import (
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
type InstanceMgr struct {
config *Config
config *Config // nolint: structcheck
instances map[string]*core.Instance
}

View File

@ -8,7 +8,7 @@ import (
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
const (
rttFailed = time.Duration(math.MaxInt64 - iota)
rttUntested
rttUnqualified
rttFailed = time.Duration(math.MaxInt64 - iota)
rttUntested // nolint: varcheck
rttUnqualified // nolint: varcheck
)

View File

@ -18,7 +18,7 @@ type Observer struct {
config *Config
ctx context.Context
statusLock sync.Mutex
statusLock sync.Mutex // nolint: structcheck
hp *HealthPing
finished *done.Instance

View File

@ -2,9 +2,9 @@
// versions:
// protoc-gen-go v1.27.1
// protoc v3.17.3
// source: app/observatory/multiObservatory/config.proto
// source: app/observatory/multiobservatory/config.proto
package multiObservatory
package multiobservatory
import (
_ "github.com/v2fly/v2ray-core/v4/common/protoext"
@ -33,7 +33,7 @@ type Config struct {
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_observatory_multiObservatory_config_proto_msgTypes[0]
mi := &file_app_observatory_multiobservatory_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -46,7 +46,7 @@ func (x *Config) String() string {
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_observatory_multiObservatory_config_proto_msgTypes[0]
mi := &file_app_observatory_multiobservatory_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -59,7 +59,7 @@ func (x *Config) ProtoReflect() protoreflect.Message {
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return file_app_observatory_multiObservatory_config_proto_rawDescGZIP(), []int{0}
return file_app_observatory_multiobservatory_config_proto_rawDescGZIP(), []int{0}
}
func (x *Config) GetHolders() *taggedfeatures.Config {
@ -69,15 +69,15 @@ func (x *Config) GetHolders() *taggedfeatures.Config {
return nil
}
var File_app_observatory_multiObservatory_config_proto protoreflect.FileDescriptor
var File_app_observatory_multiobservatory_config_proto protoreflect.FileDescriptor
var file_app_observatory_multiObservatory_config_proto_rawDesc = []byte{
var file_app_observatory_multiobservatory_config_proto_rawDesc = []byte{
0x0a, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72,
0x79, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f,
0x79, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f,
0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x2b, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e,
0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6d, 0x75, 0x6c, 0x74,
0x69, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x1a, 0x24, 0x63, 0x6f,
0x69, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x1a, 0x24, 0x63, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x74, 0x61, 0x67, 0x67, 0x65, 0x64, 0x66, 0x65, 0x61, 0x74, 0x75,
0x72, 0x65, 0x73, 0x2f, 0x73, 0x6b, 0x65, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
@ -88,7 +88,7 @@ var file_app_observatory_multiObservatory_config_proto_rawDesc = []byte{
0x6d, 0x6f, 0x6e, 0x2e, 0x74, 0x61, 0x67, 0x67, 0x65, 0x64, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72,
0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, 0x68, 0x6f, 0x6c, 0x64, 0x65,
0x72, 0x73, 0x3a, 0x23, 0x82, 0xb5, 0x18, 0x09, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x82, 0xb5, 0x18, 0x12, 0x12, 0x10, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x4f, 0x62, 0x73, 0x65,
0x65, 0x82, 0xb5, 0x18, 0x12, 0x12, 0x10, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x6f, 0x62, 0x73, 0x65,
0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x42, 0xa2, 0x01, 0x0a, 0x2f, 0x63, 0x6f, 0x6d, 0x2e,
0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f,
0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69,
@ -96,7 +96,7 @@ var file_app_observatory_multiObservatory_config_proto_rawDesc = []byte{
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x32, 0x66, 0x6c, 0x79, 0x2f,
0x76, 0x32, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x34, 0x2f, 0x61, 0x70,
0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x6d, 0x75,
0x6c, 0x74, 0x69, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0xaa, 0x02,
0x6c, 0x74, 0x69, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0xaa, 0x02,
0x2b, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e,
0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x4d, 0x75, 0x6c, 0x74,
0x69, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72,
@ -104,24 +104,24 @@ var file_app_observatory_multiObservatory_config_proto_rawDesc = []byte{
}
var (
file_app_observatory_multiObservatory_config_proto_rawDescOnce sync.Once
file_app_observatory_multiObservatory_config_proto_rawDescData = file_app_observatory_multiObservatory_config_proto_rawDesc
file_app_observatory_multiobservatory_config_proto_rawDescOnce sync.Once
file_app_observatory_multiobservatory_config_proto_rawDescData = file_app_observatory_multiobservatory_config_proto_rawDesc
)
func file_app_observatory_multiObservatory_config_proto_rawDescGZIP() []byte {
file_app_observatory_multiObservatory_config_proto_rawDescOnce.Do(func() {
file_app_observatory_multiObservatory_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_observatory_multiObservatory_config_proto_rawDescData)
func file_app_observatory_multiobservatory_config_proto_rawDescGZIP() []byte {
file_app_observatory_multiobservatory_config_proto_rawDescOnce.Do(func() {
file_app_observatory_multiobservatory_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_observatory_multiobservatory_config_proto_rawDescData)
})
return file_app_observatory_multiObservatory_config_proto_rawDescData
return file_app_observatory_multiobservatory_config_proto_rawDescData
}
var file_app_observatory_multiObservatory_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_observatory_multiObservatory_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.core.app.observatory.multiObservatory.Config
var file_app_observatory_multiobservatory_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_observatory_multiobservatory_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.core.app.observatory.multiobservatory.Config
(*taggedfeatures.Config)(nil), // 1: v2ray.core.common.taggedfeatures.Config
}
var file_app_observatory_multiObservatory_config_proto_depIdxs = []int32{
1, // 0: v2ray.core.app.observatory.multiObservatory.Config.holders:type_name -> v2ray.core.common.taggedfeatures.Config
var file_app_observatory_multiobservatory_config_proto_depIdxs = []int32{
1, // 0: v2ray.core.app.observatory.multiobservatory.Config.holders:type_name -> v2ray.core.common.taggedfeatures.Config
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
@ -129,13 +129,13 @@ var file_app_observatory_multiObservatory_config_proto_depIdxs = []int32{
0, // [0:1] is the sub-list for field type_name
}
func init() { file_app_observatory_multiObservatory_config_proto_init() }
func file_app_observatory_multiObservatory_config_proto_init() {
if File_app_observatory_multiObservatory_config_proto != nil {
func init() { file_app_observatory_multiobservatory_config_proto_init() }
func file_app_observatory_multiobservatory_config_proto_init() {
if File_app_observatory_multiobservatory_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_observatory_multiObservatory_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_app_observatory_multiobservatory_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
@ -152,18 +152,18 @@ func file_app_observatory_multiObservatory_config_proto_init() {
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_observatory_multiObservatory_config_proto_rawDesc,
RawDescriptor: file_app_observatory_multiobservatory_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_observatory_multiObservatory_config_proto_goTypes,
DependencyIndexes: file_app_observatory_multiObservatory_config_proto_depIdxs,
MessageInfos: file_app_observatory_multiObservatory_config_proto_msgTypes,
GoTypes: file_app_observatory_multiobservatory_config_proto_goTypes,
DependencyIndexes: file_app_observatory_multiobservatory_config_proto_depIdxs,
MessageInfos: file_app_observatory_multiobservatory_config_proto_msgTypes,
}.Build()
File_app_observatory_multiObservatory_config_proto = out.File
file_app_observatory_multiObservatory_config_proto_rawDesc = nil
file_app_observatory_multiObservatory_config_proto_goTypes = nil
file_app_observatory_multiObservatory_config_proto_depIdxs = nil
File_app_observatory_multiobservatory_config_proto = out.File
file_app_observatory_multiobservatory_config_proto_rawDesc = nil
file_app_observatory_multiobservatory_config_proto_goTypes = nil
file_app_observatory_multiobservatory_config_proto_depIdxs = nil
}

View File

@ -1,8 +1,8 @@
syntax = "proto3";
package v2ray.core.app.observatory.multiObservatory;
package v2ray.core.app.observatory.multiobservatory;
option csharp_namespace = "V2Ray.Core.App.Observatory.MultiObservatory";
option go_package = "github.com/v2fly/v2ray-core/v4/app/observatory/multiObservatory";
option go_package = "github.com/v2fly/v2ray-core/v4/app/observatory/multiobservatory";
option java_package = "com.v2ray.core.app.observatory.multiObservatory";
option java_multiple_files = true;
@ -11,7 +11,7 @@ import "common/protoext/extensions.proto";
message Config{
option (v2ray.core.common.protoext.message_opt).type = "service";
option (v2ray.core.common.protoext.message_opt).short_name = "multiObservatory";
option (v2ray.core.common.protoext.message_opt).short_name = "multiobservatory";
v2ray.core.common.taggedfeatures.Config holders = 1 ;
}
}

View File

@ -1,4 +1,4 @@
package multiObservatory
package multiobservatory
import (
"context"
@ -36,7 +36,7 @@ func New(ctx context.Context, config *Config) (*Observer, error) {
func (x *Config) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes []byte) error {
var err error
x.Holders, err = taggedfeatures.LoadJsonConfig(context.TODO(), "service", "background", bytes)
x.Holders, err = taggedfeatures.LoadJSONConfig(context.TODO(), "service", "background", bytes)
return err
}

View File

@ -1,175 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.17.3
// source: app/restful-api/config.proto
package restful_api
import (
_ "github.com/v2fly/v2ray-core/v4/common/protoext"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Config struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ListenAddr string `protobuf:"bytes,1,opt,name=listen_addr,json=listenAddr,proto3" json:"listen_addr,omitempty"`
ListenPort int32 `protobuf:"varint,2,opt,name=listen_port,json=listenPort,proto3" json:"listen_port,omitempty"`
AuthToken string `protobuf:"bytes,3,opt,name=auth_token,json=authToken,proto3" json:"auth_token,omitempty"`
}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_restful_api_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_restful_api_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return file_app_restful_api_config_proto_rawDescGZIP(), []int{0}
}
func (x *Config) GetListenAddr() string {
if x != nil {
return x.ListenAddr
}
return ""
}
func (x *Config) GetListenPort() int32 {
if x != nil {
return x.ListenPort
}
return 0
}
func (x *Config) GetAuthToken() string {
if x != nil {
return x.AuthToken
}
return ""
}
var File_app_restful_api_config_proto protoreflect.FileDescriptor
var file_app_restful_api_config_proto_rawDesc = []byte{
0x0a, 0x1c, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x2d, 0x61, 0x70,
0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14,
0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75,
0x6c, 0x61, 0x70, 0x69, 0x1a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x65, 0x78, 0x74, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x89, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x41, 0x64,
0x64, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x70, 0x6f, 0x72,
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x50,
0x6f, 0x72, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65,
0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b,
0x65, 0x6e, 0x3a, 0x1e, 0x82, 0xb5, 0x18, 0x09, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x82, 0xb5, 0x18, 0x0d, 0x12, 0x0b, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x2d, 0x61,
0x70, 0x69, 0x42, 0x6e, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x73, 0x74, 0x61, 0x70, 0x69,
0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76,
0x32, 0x66, 0x6c, 0x79, 0x2f, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f,
0x76, 0x34, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x2d, 0x61,
0x70, 0x69, 0x3b, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x5f, 0x61, 0x70, 0x69, 0xaa, 0x02,
0x11, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x65, 0x73, 0x74, 0x61,
0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_app_restful_api_config_proto_rawDescOnce sync.Once
file_app_restful_api_config_proto_rawDescData = file_app_restful_api_config_proto_rawDesc
)
func file_app_restful_api_config_proto_rawDescGZIP() []byte {
file_app_restful_api_config_proto_rawDescOnce.Do(func() {
file_app_restful_api_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_restful_api_config_proto_rawDescData)
})
return file_app_restful_api_config_proto_rawDescData
}
var file_app_restful_api_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_restful_api_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.app.restfulapi.Config
}
var file_app_restful_api_config_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_app_restful_api_config_proto_init() }
func file_app_restful_api_config_proto_init() {
if File_app_restful_api_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_restful_api_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_restful_api_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_restful_api_config_proto_goTypes,
DependencyIndexes: file_app_restful_api_config_proto_depIdxs,
MessageInfos: file_app_restful_api_config_proto_msgTypes,
}.Build()
File_app_restful_api_config_proto = out.File
file_app_restful_api_config_proto_rawDesc = nil
file_app_restful_api_config_proto_goTypes = nil
file_app_restful_api_config_proto_depIdxs = nil
}

View File

@ -1,4 +1,4 @@
package restful_api
package restfulapi
import (
"context"

174
app/restfulapi/config.pb.go Normal file
View File

@ -0,0 +1,174 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.17.3
// source: app/restfulapi/config.proto
package restfulapi
import (
_ "github.com/v2fly/v2ray-core/v4/common/protoext"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Config struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ListenAddr string `protobuf:"bytes,1,opt,name=listen_addr,json=listenAddr,proto3" json:"listen_addr,omitempty"`
ListenPort int32 `protobuf:"varint,2,opt,name=listen_port,json=listenPort,proto3" json:"listen_port,omitempty"`
AuthToken string `protobuf:"bytes,3,opt,name=auth_token,json=authToken,proto3" json:"auth_token,omitempty"`
}
func (x *Config) Reset() {
*x = Config{}
if protoimpl.UnsafeEnabled {
mi := &file_app_restfulapi_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Config) ProtoMessage() {}
func (x *Config) ProtoReflect() protoreflect.Message {
mi := &file_app_restfulapi_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (*Config) Descriptor() ([]byte, []int) {
return file_app_restfulapi_config_proto_rawDescGZIP(), []int{0}
}
func (x *Config) GetListenAddr() string {
if x != nil {
return x.ListenAddr
}
return ""
}
func (x *Config) GetListenPort() int32 {
if x != nil {
return x.ListenPort
}
return 0
}
func (x *Config) GetAuthToken() string {
if x != nil {
return x.AuthToken
}
return ""
}
var File_app_restfulapi_config_proto protoreflect.FileDescriptor
var file_app_restfulapi_config_proto_rawDesc = []byte{
0x0a, 0x1b, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x61, 0x70, 0x69,
0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x76,
0x32, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c,
0x61, 0x70, 0x69, 0x1a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x65, 0x78, 0x74, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x88, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x41, 0x64, 0x64,
0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x70, 0x6f, 0x72, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x50, 0x6f,
0x72, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65,
0x6e, 0x3a, 0x1d, 0x82, 0xb5, 0x18, 0x09, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x82, 0xb5, 0x18, 0x0c, 0x12, 0x0a, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x61, 0x70, 0x69,
0x42, 0x61, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x65, 0x73, 0x74, 0x61, 0x70, 0x69, 0x50, 0x01,
0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x32, 0x66,
0x6c, 0x79, 0x2f, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x34,
0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x65, 0x73, 0x74, 0x66, 0x75, 0x6c, 0x61, 0x70, 0x69, 0xaa,
0x02, 0x11, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x65, 0x73, 0x74,
0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_app_restfulapi_config_proto_rawDescOnce sync.Once
file_app_restfulapi_config_proto_rawDescData = file_app_restfulapi_config_proto_rawDesc
)
func file_app_restfulapi_config_proto_rawDescGZIP() []byte {
file_app_restfulapi_config_proto_rawDescOnce.Do(func() {
file_app_restfulapi_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_restfulapi_config_proto_rawDescData)
})
return file_app_restfulapi_config_proto_rawDescData
}
var file_app_restfulapi_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_app_restfulapi_config_proto_goTypes = []interface{}{
(*Config)(nil), // 0: v2ray.app.restfulapi.Config
}
var file_app_restfulapi_config_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_app_restfulapi_config_proto_init() }
func file_app_restfulapi_config_proto_init() {
if File_app_restfulapi_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_app_restfulapi_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_app_restfulapi_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_app_restfulapi_config_proto_goTypes,
DependencyIndexes: file_app_restfulapi_config_proto_depIdxs,
MessageInfos: file_app_restfulapi_config_proto_msgTypes,
}.Build()
File_app_restfulapi_config_proto = out.File
file_app_restfulapi_config_proto_rawDesc = nil
file_app_restfulapi_config_proto_goTypes = nil
file_app_restfulapi_config_proto_depIdxs = nil
}

View File

@ -2,7 +2,7 @@ syntax = "proto3";
package v2ray.app.restfulapi;
option csharp_namespace = "V2Ray.App.Restapi";
option go_package = "github.com/v2fly/v2ray-core/v4/app/restful-api;restful_api";
option go_package = "github.com/v2fly/v2ray-core/v4/app/restfulapi";
option java_package = "com.v2ray.core.app.restapi";
option java_multiple_files = true;
@ -10,9 +10,9 @@ import "common/protoext/extensions.proto";
message Config{
option (v2ray.core.common.protoext.message_opt).type = "service";
option (v2ray.core.common.protoext.message_opt).short_name = "restful-api";
option (v2ray.core.common.protoext.message_opt).short_name = "restfulapi";
string listen_addr = 1;
int32 listen_port = 2;
string auth_token = 3;
}
}

View File

@ -1,4 +1,4 @@
package restful_api
package restfulapi
import "github.com/v2fly/v2ray-core/v4/common/errors"

View File

@ -1,4 +1,4 @@
package restful_api
package restfulapi
import (
"net/http"

View File

@ -1,4 +1,4 @@
package restful_api
package restfulapi
import (
"context"

View File

@ -1,4 +1,4 @@
package restful_api
package restfulapi
import (
"reflect"

View File

@ -178,7 +178,7 @@ func (br *BalancingRule) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes
if stub.Strategy == "" {
stub.Strategy = "random"
}
settingsPack, err := v5cfg.LoadHeterogeneousConfigFromRawJson(context.TODO(), "balancer", stub.Strategy, stub.StrategySettings)
settingsPack, err := v5cfg.LoadHeterogeneousConfigFromRawJSON(context.TODO(), "balancer", stub.Strategy, stub.StrategySettings)
if err != nil {
return err
}

View File

@ -173,7 +173,6 @@ func init() {
var routingRules []*RoutingRule
for _, v := range simplifiedConfig.Rule {
rule := new(RoutingRule)
for _, geo := range v.Geoip {

View File

@ -64,8 +64,8 @@ func (l *LeastLoadStrategy) InjectContext(ctx context.Context) {
l.ctx = ctx
}
func (s *LeastLoadStrategy) PickOutbound(candidates []string) string {
selects := s.pickOutbounds(candidates)
func (l *LeastLoadStrategy) PickOutbound(candidates []string) string {
selects := l.pickOutbounds(candidates)
count := len(selects)
if count == 0 {
// goes to fallbackTag
@ -74,9 +74,9 @@ func (s *LeastLoadStrategy) PickOutbound(candidates []string) string {
return selects[dice.Roll(count)].Tag
}
func (s *LeastLoadStrategy) pickOutbounds(candidates []string) []*node {
qualified := s.getNodes(candidates, time.Duration(s.settings.MaxRTT))
selects := s.selectLeastLoad(qualified)
func (l *LeastLoadStrategy) pickOutbounds(candidates []string) []*node {
qualified := l.getNodes(candidates, time.Duration(l.settings.MaxRTT))
selects := l.selectLeastLoad(qualified)
return selects
}
@ -96,12 +96,12 @@ func (s *LeastLoadStrategy) pickOutbounds(candidates []string) []*node {
// 3. Speed priority: Baselines + `Expected Count <= 0`.
// go through all baselines until find selects, if not, select none. Used in combination
// with 'balancer.fallbackTag', it means: selects qualified nodes or use the fallback.
func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
func (l *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
if len(nodes) == 0 {
newError("least load: no qualified outbound").AtInfo().WriteToLog()
return nil
}
expected := int(s.settings.Expected)
expected := int(l.settings.Expected)
availableCount := len(nodes)
if expected > availableCount {
return nodes
@ -110,13 +110,13 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
if expected <= 0 {
expected = 1
}
if len(s.settings.Baselines) == 0 {
if len(l.settings.Baselines) == 0 {
return nodes[:expected]
}
count := 0
// go through all base line until find expected selects
for _, b := range s.settings.Baselines {
for _, b := range l.settings.Baselines {
baseline := time.Duration(b)
for i := 0; i < availableCount; i++ {
if nodes[i].RTTDeviationCost > baseline {
@ -130,30 +130,30 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
break
}
}
if s.settings.Expected > 0 && count < expected {
if l.settings.Expected > 0 && count < expected {
count = expected
}
return nodes[:count]
}
func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node {
if s.observer == nil {
common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error {
s.observer = observatory
func (l *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node {
if l.observer == nil {
common.Must(core.RequireFeatures(l.ctx, func(observatory extension.Observatory) error {
l.observer = observatory
return nil
}))
}
var result proto.Message
if s.settings.ObserverTag == "" {
observeResult, err := s.observer.GetObservation(s.ctx)
if l.settings.ObserverTag == "" {
observeResult, err := l.observer.GetObservation(l.ctx)
if err != nil {
newError("cannot get observation").Base(err).WriteToLog()
return make([]*node, 0)
}
result = observeResult
} else {
observeResult, err := common.Must2(s.observer.(features.TaggedFeatures).GetFeaturesByTag(s.settings.ObserverTag)).(extension.Observatory).GetObservation(s.ctx)
observeResult, err := common.Must2(l.observer.(features.TaggedFeatures).GetFeaturesByTag(l.settings.ObserverTag)).(extension.Observatory).GetObservation(l.ctx)
if err != nil {
newError("cannot get observation").Base(err).WriteToLog()
return make([]*node, 0)
@ -175,16 +175,15 @@ func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration)
CountFail: 1,
RTTAverage: time.Duration(v.Delay) * time.Millisecond,
RTTDeviation: time.Duration(v.Delay) * time.Millisecond,
RTTDeviationCost: time.Duration(s.costs.Apply(v.OutboundTag, float64(time.Duration(v.Delay)*time.Millisecond))),
RTTDeviationCost: time.Duration(l.costs.Apply(v.OutboundTag, float64(time.Duration(v.Delay)*time.Millisecond))),
}
if v.HealthPing != nil {
record.RTTAverage = time.Duration(v.HealthPing.Average)
record.RTTDeviation = time.Duration(v.HealthPing.Deviation)
record.RTTDeviationCost = time.Duration(s.costs.Apply(v.OutboundTag, float64(v.HealthPing.Deviation)))
record.RTTDeviationCost = time.Duration(l.costs.Apply(v.OutboundTag, float64(v.HealthPing.Deviation)))
record.CountAll = int(v.HealthPing.All)
record.CountFail = int(v.HealthPing.Fail)
}
ret = append(ret, record)
}

View File

@ -24,10 +24,7 @@ func LoadArg(arg string) (out io.Reader, err error) {
// LoadArgToBytes loads one arg to []byte, maybe an remote url, or local file path
func LoadArgToBytes(arg string) (out []byte, err error) {
switch {
default:
out, err = ioutil.ReadFile(arg)
}
out, err = ioutil.ReadFile(arg)
if err != nil {
return
}

View File

@ -13,8 +13,5 @@ func ContextWithEnvironment(ctx context.Context, environment interface{}) contex
}
func EnvironmentFromContext(ctx context.Context) interface{} {
if environment, ok := ctx.Value(environmentKey).(interface{}); ok {
return environment
}
return nil
return ctx.Value(environmentKey)
}

View File

@ -41,7 +41,7 @@ func ParseNetwork(net string) Network {
}
func ParseNetworks(netlist string) []Network {
strlist := strings.Split(string(netlist), ",")
strlist := strings.Split(netlist, ",")
nl := make([]Network, len(strlist))
for idx, network := range strlist {
nl[idx] = ParseNetwork(network)

View File

@ -10,22 +10,18 @@ import (
func GetMessageOptions(msgDesc protoreflect.MessageDescriptor) (*MessageOpt, error) {
msgOpt := msgDesc.Options().(*descriptorpb.MessageOptions)
var V2MessageOption *MessageOpt
if msgOptRet, err := proto.GetExtension(msgOpt, E_MessageOpt); err != nil {
msgOptRet, err := proto.GetExtension(msgOpt, E_MessageOpt)
if err != nil {
return nil, newError("unable to parse extension from message").Base(err)
} else {
V2MessageOption = msgOptRet.(*MessageOpt)
}
return V2MessageOption, nil
return msgOptRet.(*MessageOpt), nil
}
func GetFieldOptions(fieldDesc protoreflect.FieldDescriptor) (*FieldOpt, error) {
fieldOpt := fieldDesc.Options().(*descriptorpb.FieldOptions)
var V2FieldOption *FieldOpt
if msgOptRet, err := proto.GetExtension(fieldOpt, E_FieldOpt); err != nil {
msgOptRet, err := proto.GetExtension(fieldOpt, E_FieldOpt)
if err != nil {
return nil, newError("unable to parse extension from message").Base(err)
} else {
V2FieldOption = msgOptRet.(*FieldOpt)
}
return V2FieldOption, nil
return msgOptRet.(*FieldOpt), nil
}

View File

@ -53,8 +53,7 @@ func filterMessage(ctx context.Context, message protoreflect.Message) error {
}
if v2extension.ConvertTimeParseIp != "" {
strIp := value.String()
ipValue := net.ParseIP(strIp)
ipValue := net.ParseIP(value.String())
target := message.Descriptor().Fields().ByTextName(v2extension.ConvertTimeParseIp)
pendingWriteQueue = append(pendingWriteQueue, pendingWrite{
field: target,
@ -116,10 +115,7 @@ func filterMap(ctx context.Context, mapValue protoreflect.Map) error {
var err error
mapValue.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
err = filterMessage(ctx, value.Message())
if err != nil {
return false
}
return true
return err == nil
})
return err
}

View File

@ -14,7 +14,7 @@ const (
muxPreferedSessionKey
sockoptSessionKey
trackedConnectionErrorKey
handlerSessionKey
handlerSessionKey // nolint: varcheck
)
// ContextWithID returns a new context with the given ID.

View File

@ -10,7 +10,7 @@ import (
"github.com/v2fly/v2ray-core/v4/infra/conf/v5cfg"
)
func LoadJsonConfig(ctx context.Context, interfaceType, defaultImpl string, message json.RawMessage) (*Config, error) {
func LoadJSONConfig(ctx context.Context, interfaceType, defaultImpl string, message json.RawMessage) (*Config, error) {
type ItemStub struct {
MemberType string `json:"type"`
Tag string `json:"tag"`
@ -27,7 +27,7 @@ func LoadJsonConfig(ctx context.Context, interfaceType, defaultImpl string, mess
if v.MemberType == "" {
v.MemberType = defaultImpl
}
pack, err := v5cfg.LoadHeterogeneousConfigFromRawJson(ctx, interfaceType, v.MemberType, v.Value)
pack, err := v5cfg.LoadHeterogeneousConfigFromRawJSON(ctx, interfaceType, v.MemberType, v.Value)
if err != nil {
return nil, err
}

View File

@ -154,9 +154,8 @@ func loadSingleConfigAutoFormat(input interface{}) (*Config, error) {
c, err := f.Loader(input)
if err == nil {
return c, nil
} else {
errorReasons.WriteString(fmt.Sprintf("unable to parse as %v:%v;", f.Name[0], err.Error()))
}
errorReasons.WriteString(fmt.Sprintf("unable to parse as %v:%v;", f.Name[0], err.Error()))
}
return nil, newError("tried all loaders but failed when attempting to parse: ", input, ";", errorReasons.String()).AtWarning()
}

View File

@ -32,5 +32,5 @@ func mapToJSON(tree *toml.Tree) (string, error) {
if err != nil {
return "", err
}
return string(bytes[:]), nil
return string(bytes), nil
}

View File

@ -16,7 +16,7 @@ import (
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
func loadJsonPb(data io.Reader) (*core.Config, error) {
func loadJSONPB(data io.Reader) (*core.Config, error) {
coreconf := &core.Config{}
jsonpbloader := &jsonpb.Unmarshaler{AnyResolver: serial.GetResolver()}
err := jsonpbloader.Unmarshal(data, coreconf)
@ -26,7 +26,7 @@ func loadJsonPb(data io.Reader) (*core.Config, error) {
return coreconf, nil
}
func dumpJsonPb(config proto.Message, w io.Writer) error {
func dumpJSONPb(config proto.Message, w io.Writer) error {
jsonpbdumper := &jsonpb.Marshaler{AnyResolver: serial.GetResolver()}
err := jsonpbdumper.Marshal(w, config)
if err != nil {
@ -35,8 +35,8 @@ func dumpJsonPb(config proto.Message, w io.Writer) error {
return nil
}
func DumpJsonPb(config proto.Message, w io.Writer) error {
return dumpJsonPb(config, w)
func DumpJSONPb(config proto.Message, w io.Writer) error {
return dumpJSONPb(config, w)
}
const FormatProtobufJSONPB = "jsonpb"
@ -56,13 +56,13 @@ func init() {
if err != nil {
return nil, err
}
return loadJsonPb(bytes.NewReader(data))
return loadJSONPB(bytes.NewReader(data))
case io.Reader:
data, err := buf.ReadAllToBytes(v)
if err != nil {
return nil, err
}
return loadJsonPb(bytes.NewReader(data))
return loadJSONPB(bytes.NewReader(data))
default:
return nil, newError("unknow type")
}

View File

@ -8,7 +8,7 @@ import (
core "github.com/v2fly/v2ray-core/v4"
"github.com/v2fly/v2ray-core/v4/common/errors"
json_reader "github.com/v2fly/v2ray-core/v4/infra/conf/json"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
)
type offset struct {

View File

@ -139,7 +139,7 @@ var typeMap = map[routercommon.Domain_Type]dns.DomainMatchingType{
}
// DNSConfig is a JSON serializable object for dns.Config.
type DNSConfig struct {
type DNSConfig struct { // nolint: revive
Servers []*NameServerConfig `json:"servers"`
Hosts map[string]*HostAddress `json:"hosts"`
ClientIP *cfgcommon.Address `json:"clientIp"`
@ -216,7 +216,6 @@ func (c *DNSConfig) Build() (*dns.Config, error) {
} else {
return nil, newError("unable to create geo data loader ").Base(err)
}
}
cfgEnv := cfgcommon.GetConfigureLoadingEnvironment(c.cfgctx)

View File

@ -14,7 +14,7 @@ func DefaultLogConfig() *log.Config {
}
}
type LogConfig struct {
type LogConfig struct { // nolint: revive
AccessLog string `json:"access"`
ErrorLog string `json:"error"`
LogLevel string `json:"loglevel"`

View File

@ -17,7 +17,7 @@ import (
rule2 "github.com/v2fly/v2ray-core/v4/infra/conf/rule"
)
type RouterRulesConfig struct {
type RouterRulesConfig struct { // nolint: revive
RuleList []json.RawMessage `json:"rules"`
DomainStrategy string `json:"domainStrategy"`
}
@ -82,7 +82,7 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) {
}, nil
}
type RouterConfig struct {
type RouterConfig struct { // nolint: revive
Settings *RouterRulesConfig `json:"settings"` // Deprecated
RuleList []json.RawMessage `json:"rules"`
DomainStrategy *string `json:"domainStrategy"`

View File

@ -89,18 +89,18 @@ func (v *V2JsonProtobufFollower) Clear(descriptor protoreflect.FieldDescriptor)
}
func (v *V2JsonProtobufFollower) Set(descriptor protoreflect.FieldDescriptor, value protoreflect.Value) {
switch descriptor.(type) {
switch descriptor := descriptor.(type) {
case V2JsonProtobufFollowerFieldDescriptor:
v.Message.Set(descriptor.(V2JsonProtobufFollowerFieldDescriptor).FieldDescriptor, value)
v.Message.Set(descriptor.FieldDescriptor, value)
case *V2JsonProtobufFollowerFieldDescriptor:
v.Message.Set(descriptor.(*V2JsonProtobufFollowerFieldDescriptor).FieldDescriptor, value)
v.Message.Set(descriptor.FieldDescriptor, value)
case *V2JsonProtobufAnyValueField:
protodata := value.Message()
bytesw, err := proto.MarshalOptions{AllowPartial: true}.Marshal(&V2JsonProtobufAnyValueFieldReturn{protodata})
if err != nil {
panic(err)
}
v.Message.Set(descriptor.(*V2JsonProtobufAnyValueField).FieldDescriptor, protoreflect.ValueOfBytes(bytesw))
v.Message.Set(descriptor.FieldDescriptor, protoreflect.ValueOfBytes(bytesw))
default:
v.Message.Set(descriptor, value)
}
@ -122,9 +122,7 @@ func (v *V2JsonProtobufFollower) Mutable(descriptor protoreflect.FieldDescriptor
func (v *V2JsonProtobufFollower) NewField(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
if _, ok := descriptor.(*V2JsonProtobufAnyValueField); ok {
url := v.Message.Get(v.Message.Descriptor().Fields().ByName("type_url")).String()
v2type := serial.V2TypeFromURL(url)
instance, err := serial.GetInstance(v2type)
if err != nil {

View File

@ -6,7 +6,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
)

View File

@ -6,7 +6,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/dns"
)

View File

@ -6,7 +6,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/dokodemo"
)

View File

@ -7,7 +7,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
)

View File

@ -5,7 +5,7 @@ import (
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/http"
)

View File

@ -8,7 +8,7 @@ import (
"github.com/v2fly/v2ray-core/v4/app/observatory"
"github.com/v2fly/v2ray-core/v4/app/observatory/burst"
"github.com/v2fly/v2ray-core/v4/app/observatory/multiObservatory"
"github.com/v2fly/v2ray-core/v4/app/observatory/multiobservatory"
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/common/taggedfeatures"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/duration"
@ -32,11 +32,11 @@ type BurstObservatoryConfig struct {
}
func (b BurstObservatoryConfig) Build() (proto.Message, error) {
if result, err := b.HealthCheck.Build(); err == nil {
result, err := b.HealthCheck.Build()
if err == nil {
return &burst.Config{SubjectSelector: b.SubjectSelector, PingConfig: result.(*burst.HealthPingConfig)}, nil
} else {
return nil, err
}
return nil, err
}
type MultiObservatoryItem struct {
@ -50,7 +50,7 @@ type MultiObservatoryConfig struct {
}
func (o *MultiObservatoryConfig) Build() (proto.Message, error) {
ret := &multiObservatory.Config{Holders: &taggedfeatures.Config{Features: make(map[string]*anypb.Any)}}
ret := &multiobservatory.Config{Holders: &taggedfeatures.Config{Features: make(map[string]*anypb.Any)}}
for _, v := range o.Observers {
switch v.MemberType {
case "burst":
@ -64,7 +64,6 @@ func (o *MultiObservatoryConfig) Build() (proto.Message, error) {
return nil, err
}
ret.Holders.Features[v.Tag] = serial.ToTypedMessage(burstObservatoryConfigPb)
break
case "default":
fallthrough
default:

View File

@ -4,7 +4,7 @@ import (
"testing"
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
)
func TestBufferSize(t *testing.T) {

View File

@ -6,7 +6,7 @@ import (
"github.com/v2fly/v2ray-core/v4/app/reverse"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
)
func TestReverseConfig(t *testing.T) {

View File

@ -8,7 +8,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/shadowsocks"
)

View File

@ -8,7 +8,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/socks"
)

View File

@ -10,7 +10,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/socketcfg"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/transport"
"github.com/v2fly/v2ray-core/v4/transport/internet"
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/http"

View File

@ -471,7 +471,7 @@ func (c *Config) Build() (*core.Config, error) {
" instead of allowing end user to enable it without special tool and knowledge.")
sb := strings.Builder{}
return nil, newError("Cannot load service").Base(developererr).Base(err).Base(newError(sb.String()))
} else { // nolint: golint
} else { // nolint: revive
// Using a else here is required to keep msg in scope
config.App = append(config.App, msg...)
}

View File

@ -25,7 +25,7 @@ import (
// Geo loaders
_ "github.com/v2fly/v2ray-core/v4/infra/conf/geodata/memconservative"
_ "github.com/v2fly/v2ray-core/v4/infra/conf/geodata/standard"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
dns_proxy "github.com/v2fly/v2ray-core/v4/proxy/dns"
"github.com/v2fly/v2ray-core/v4/proxy/freedom"

View File

@ -8,7 +8,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/vless"
"github.com/v2fly/v2ray-core/v4/proxy/vless/inbound"
"github.com/v2fly/v2ray-core/v4/proxy/vless/outbound"

View File

@ -8,7 +8,7 @@ import (
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
"github.com/v2fly/v2ray-core/v4/proxy/vmess"
"github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound"
"github.com/v2fly/v2ray-core/v4/proxy/vmess/outbound"

View File

@ -11,16 +11,16 @@ import (
"github.com/v2fly/v2ray-core/v4/common/registry"
)
func loadHeterogeneousConfigFromRawJson(interfaceType, name string, rawJson json.RawMessage) (proto.Message, error) {
func loadHeterogeneousConfigFromRawJSON(interfaceType, name string, rawJSON json.RawMessage) (proto.Message, error) {
fsdef := envimpl.NewDefaultFileSystemDefaultImpl()
ctx := envctx.ContextWithEnvironment(context.TODO(), fsdef)
if rawJson == nil || len(rawJson) == 0 {
rawJson = []byte("{}")
if rawJSON == nil || len(rawJSON) == 0 {
rawJSON = []byte("{}")
}
return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJson))
return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJSON))
}
// LoadHeterogeneousConfigFromRawJson private API
func LoadHeterogeneousConfigFromRawJson(ctx context.Context, interfaceType, name string, rawJson json.RawMessage) (proto.Message, error) {
return loadHeterogeneousConfigFromRawJson(interfaceType, name, rawJson)
// LoadHeterogeneousConfigFromRawJSON private API
func LoadHeterogeneousConfigFromRawJSON(ctx context.Context, interfaceType, name string, rawJSON json.RawMessage) (proto.Message, error) {
return loadHeterogeneousConfigFromRawJSON(interfaceType, name, rawJSON)
}

View File

@ -64,7 +64,7 @@ func (c InboundConfig) BuildV5(ctx context.Context) (proto.Message, error) {
c.Settings = []byte("{}")
}
inboundConfigPack, err := loadHeterogeneousConfigFromRawJson("inbound", c.Protocol, c.Settings)
inboundConfigPack, err := loadHeterogeneousConfigFromRawJSON("inbound", c.Protocol, c.Settings)
if err != nil {
return nil, newError("unable to load inbound protocol config").Base(err)
}

View File

@ -26,13 +26,13 @@ func init() {
if err != nil {
return nil, err
}
return loadJsonConfig(data)
return loadJSONConfig(data)
case io.Reader:
data, err := buf.ReadAllToBytes(v)
if err != nil {
return nil, err
}
return loadJsonConfig(data)
return loadJSONConfig(data)
default:
return nil, newError("unknown type")
}

View File

@ -46,7 +46,7 @@ func (c OutboundConfig) BuildV5(ctx context.Context) (proto.Message, error) {
c.Settings = []byte("{}")
}
outboundConfigPack, err := loadHeterogeneousConfigFromRawJson("outbound", c.Protocol, c.Settings)
outboundConfigPack, err := loadHeterogeneousConfigFromRawJSON("outbound", c.Protocol, c.Settings)
if err != nil {
return nil, newError("unable to load outbound protocol config").Base(err)
}

View File

@ -28,7 +28,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
var logConfMsg *anypb.Any
if c.LogConfig != nil {
logConfMsgUnpacked, err := loadHeterogeneousConfigFromRawJson("service", "log", c.LogConfig)
logConfMsgUnpacked, err := loadHeterogeneousConfigFromRawJSON("service", "log", c.LogConfig)
if err != nil {
return nil, err
}
@ -41,7 +41,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
config.App = append([]*anypb.Any{logConfMsg}, config.App...)
if c.RouterConfig != nil {
routerConfig, err := loadHeterogeneousConfigFromRawJson("service", "router", c.RouterConfig)
routerConfig, err := loadHeterogeneousConfigFromRawJSON("service", "router", c.RouterConfig)
if err != nil {
return nil, err
}
@ -49,7 +49,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
}
if c.DNSConfig != nil {
dnsApp, err := loadHeterogeneousConfigFromRawJson("service", "dns", c.DNSConfig)
dnsApp, err := loadHeterogeneousConfigFromRawJSON("service", "dns", c.DNSConfig)
if err != nil {
return nil, newError("failed to parse DNS config").Base(err)
}
@ -73,7 +73,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
}
for serviceName, service := range c.Services {
servicePackedConfig, err := loadHeterogeneousConfigFromRawJson("service", serviceName, service)
servicePackedConfig, err := loadHeterogeneousConfigFromRawJSON("service", serviceName, service)
if err != nil {
return nil, err
}
@ -82,7 +82,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
return config, nil
}
func loadJsonConfig(data []byte) (*core.Config, error) {
func loadJSONConfig(data []byte) (*core.Config, error) {
rootConfig := &RootConfig{}
err := json.Unmarshal(data, rootConfig)

View File

@ -22,7 +22,7 @@ func (s StreamConfig) BuildV5(ctx context.Context) (proto.Message, error) {
if s.TransportSettings == nil {
s.TransportSettings = []byte("{}")
}
transportConfigPack, err := loadHeterogeneousConfigFromRawJson("transport", s.Transport, s.TransportSettings)
transportConfigPack, err := loadHeterogeneousConfigFromRawJSON("transport", s.Transport, s.TransportSettings)
if err != nil {
return nil, newError("unable to load transport config").Base(err)
}
@ -37,7 +37,7 @@ func (s StreamConfig) BuildV5(ctx context.Context) (proto.Message, error) {
if s.SecuritySettings == nil {
s.SecuritySettings = []byte("{}")
}
securityConfigPack, err := loadHeterogeneousConfigFromRawJson("security", s.Security, s.SecuritySettings)
securityConfigPack, err := loadHeterogeneousConfigFromRawJSON("security", s.Security, s.SecuritySettings)
if err != nil {
return nil, newError("unable to load security config").Base(err)
}

View File

@ -80,7 +80,7 @@ func dialAPIServerWithContext(ctx context.Context) (conn *grpc.ClientConn) {
return
}
func protoToJSONString(m proto.Message, prefix, indent string) (string, error) {
func protoToJSONString(m proto.Message, prefix, indent string) (string, error) { // nolint: unparam
return strings.TrimSpace(protojson.MarshalOptions{Indent: indent}.Format(m)), nil
}

View File

@ -41,11 +41,9 @@ var cmdConvertPb = &base.Command{
if len(configFiles) == 0 {
base.Fatalf("%s", newError("failed to load config").Base(err))
return
} else {
base.Fatalf("%s", newError(fmt.Sprintf("failed to load config: %s", configFiles)).Base(err))
return
}
base.Fatalf("%s", newError(fmt.Sprintf("failed to load config: %s", configFiles)).Base(err))
return
}
bytew, err := proto.Marshal(config)
if err != nil {

View File

@ -31,7 +31,7 @@ var cmdReversePb = &base.Command{
}
switch *configFormat {
case "jsonpb":
if err := jsonpb.DumpJsonPb(&conf, os.Stdout); err != nil {
if err := jsonpb.DumpJSONPb(&conf, os.Stdout); err != nil {
base.Fatalf("%s", err)
}
case "v2jsonpb":

View File

@ -136,7 +136,7 @@ func executeConvert(cmd *base.Command, args []string) {
base.Fatalf(err.Error())
}
w := bytes.NewBuffer(nil)
err = jsonpb.DumpJsonPb(pbConfig, w)
err = jsonpb.DumpJSONPb(pbConfig, w)
if err != nil {
base.Fatalf(err.Error())
}

View File

@ -7,7 +7,7 @@ import (
"github.com/v2fly/v2ray-core/v4/infra/conf/merge"
"github.com/v2fly/v2ray-core/v4/infra/conf/mergers"
"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
"github.com/v2fly/v2ray-core/v4/infra/conf/v4"
v4 "github.com/v2fly/v2ray-core/v4/infra/conf/v4"
)
// LoadConfig load config files to *conf.Config, it will:

View File

@ -33,7 +33,7 @@ import (
// Developer preview features
_ "github.com/v2fly/v2ray-core/v4/app/instman"
_ "github.com/v2fly/v2ray-core/v4/app/observatory"
_ "github.com/v2fly/v2ray-core/v4/app/restful-api"
_ "github.com/v2fly/v2ray-core/v4/app/restfulapi"
// Inbound and outbound proxies.
_ "github.com/v2fly/v2ray-core/v4/proxy/blackhole"
@ -89,6 +89,7 @@ import (
// V5 version of json configure file parser
_ "github.com/v2fly/v2ray-core/v4/infra/conf/v5cfg"
// Simplified config
_ "github.com/v2fly/v2ray-core/v4/proxy/http/simplified"
_ "github.com/v2fly/v2ray-core/v4/proxy/shadowsocks/simplified"
_ "github.com/v2fly/v2ray-core/v4/proxy/socks/simplified"

View File

@ -12,6 +12,8 @@ import (
"github.com/v2fly/v2ray-core/v4/app/router"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/serial"
// Initialization
_ "github.com/v2fly/v2ray-core/v4/main/distro/all"
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
"github.com/v2fly/v2ray-core/v4/proxy/dokodemo"
@ -77,7 +79,6 @@ func (b *bindingInstance) startAPIInstance() {
panic(err)
}
b.instance = instance
return
}
func withDefaultApps(config *core.Config) *core.Config {

View File

@ -146,7 +146,7 @@ func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, e
iv = make([]byte, account.Cipher.IVSize())
if n, err := io.ReadFull(reader, iv); err != nil {
return nil, newError("failed to read IV").Base(err)
} else { // nolint: golint
} else { // nolint: revive
drainer.AcknowledgeReceive(n)
}
}

View File

@ -239,12 +239,12 @@ func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon
if n, err := io.ReadFull(reader, aeadEncryptedResponseHeaderLength[:]); err != nil {
c.readDrainer.AcknowledgeReceive(n)
return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Len").Base(err))
} else { // nolint: golint
} else { // nolint: revive
c.readDrainer.AcknowledgeReceive(n)
}
if decryptedResponseHeaderLengthBinaryBuffer, err := aeadResponseHeaderLengthEncryptionAEAD.Open(nil, aeadResponseHeaderLengthEncryptionIV, aeadEncryptedResponseHeaderLength[:], nil); err != nil {
return nil, drain.WithError(c.readDrainer, reader, newError("Failed To Decrypt Length").Base(err))
} else { // nolint: golint
} else { // nolint: revive
common.Must(binary.Read(bytes.NewReader(decryptedResponseHeaderLengthBinaryBuffer), binary.BigEndian, &decryptedResponseHeaderLengthBinaryDeserializeBuffer))
decryptedResponseHeaderLength = int(decryptedResponseHeaderLengthBinaryDeserializeBuffer)
}
@ -260,13 +260,13 @@ func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon
if n, err := io.ReadFull(reader, encryptedResponseHeaderBuffer); err != nil {
c.readDrainer.AcknowledgeReceive(n)
return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Data").Base(err))
} else { // nolint: golint
} else { // nolint: revive
c.readDrainer.AcknowledgeReceive(n)
}
if decryptedResponseHeaderBuffer, err := aeadResponseHeaderPayloadEncryptionAEAD.Open(nil, aeadResponseHeaderPayloadEncryptionIV, encryptedResponseHeaderBuffer, nil); err != nil {
return nil, drain.WithError(c.readDrainer, reader, newError("Failed To Decrypt Payload").Base(err))
} else { // nolint: golint
} else { // nolint: revive
c.responseReader = bytes.NewReader(decryptedResponseHeaderBuffer)
}
}

View File

@ -112,7 +112,7 @@ func (h *HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
// Parse the request
if req, err := readRequest(bufio.NewReader(bytes.NewReader(headerBuf.Bytes()))); err != nil {
return nil, err
} else { // nolint: golint
} else { // nolint: revive
h.req = req
}

View File

@ -19,7 +19,7 @@ type PacketWriter interface {
io.Writer
}
type KCPPacketReader struct { // nolint: golint
type KCPPacketReader struct { // nolint: revive
Security cipher.AEAD
Header internet.PacketHeader
}
@ -55,7 +55,7 @@ func (r *KCPPacketReader) Read(b []byte) []Segment {
return result
}
type KCPPacketWriter struct { // nolint: golint
type KCPPacketWriter struct { // nolint: revive
Header internet.PacketHeader
Security cipher.AEAD
Writer io.Writer

View File

@ -6,11 +6,11 @@ import (
const (
// TCP_FASTOPEN is the socket option on darwin for TCP fast open.
TCP_FASTOPEN = 0x105 // nolint: golint,stylecheck
TCP_FASTOPEN = 0x105 // nolint: revive,stylecheck
// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
TCP_FASTOPEN_SERVER = 0x01 // nolint: golint,stylecheck
TCP_FASTOPEN_SERVER = 0x01 // nolint: revive,stylecheck
// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
TCP_FASTOPEN_CLIENT = 0x02 // nolint: golint,stylecheck
TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
)
func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {

View File

@ -9,9 +9,9 @@ import (
const (
// For incoming connections.
TCP_FASTOPEN = 23 // nolint: golint,stylecheck
TCP_FASTOPEN = 23 // nolint: revive,stylecheck
// For out-going connections.
TCP_FASTOPEN_CONNECT = 30 // nolint: golint,stylecheck
TCP_FASTOPEN_CONNECT = 30 // nolint: revive,stylecheck
)
func bindAddr(fd uintptr, ip []byte, port uint32) error {

View File

@ -3,7 +3,7 @@ package internet
import "syscall"
const (
TCP_FASTOPEN = 15 // nolint: golint,stylecheck
TCP_FASTOPEN = 15 // nolint: revive,stylecheck
)
func setTFO(fd syscall.Handle, settings SocketConfig_TCPFastOpenState) error {

View File

@ -70,7 +70,7 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S
if err != nil {
return nil, err
}
ctx = context.WithValue(ctx, address, locker) // nolint: golint,staticcheck
ctx = context.WithValue(ctx, address, locker) // nolint: revive,staticcheck
}
}

View File

@ -10,7 +10,7 @@ import (
"github.com/v2fly/v2ray-core/v4/transport/internet"
)
const SO_ORIGINAL_DST = 80 // nolint: golint,stylecheck
const SO_ORIGINAL_DST = 80 // nolint: revive,stylecheck
func GetOriginalDestination(conn internet.Connection) (net.Destination, error) {
sysrawconn, f := conn.(syscall.Conn)