1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-13 12:56:38 -05:00

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"
)