mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-10 10:37:24 -05:00
Lint: fix lint (#1427)
* Lint: replace golint with revive * Lint: fix lint
This commit is contained in:
parent
43447aa2e4
commit
dce8764fd7
4
.github/linters/.golangci.yml
vendored
4
.github/linters/.golangci.yml
vendored
@ -7,7 +7,7 @@ issues:
|
|||||||
new: true
|
new: true
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- linters:
|
- linters:
|
||||||
- staticcheck
|
- staticcheck
|
||||||
text: "SA1019:"
|
text: "SA1019:"
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
@ -19,13 +19,13 @@ linters:
|
|||||||
- gofmt
|
- gofmt
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- goimports
|
- goimports
|
||||||
- golint
|
|
||||||
- goprintffuncname
|
- goprintffuncname
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
|
- revive
|
||||||
- rowserrcheck
|
- rowserrcheck
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
- structcheck
|
||||||
|
@ -117,7 +117,7 @@ func init() {
|
|||||||
Service: nil,
|
Service: nil,
|
||||||
}
|
}
|
||||||
for _, v := range simplifiedConfig.Name {
|
for _, v := range simplifiedConfig.Name {
|
||||||
pack, err := v5cfg.LoadHeterogeneousConfigFromRawJson(ctx, "grpcservice", v, []byte("{}"))
|
pack, err := v5cfg.LoadHeterogeneousConfigFromRawJSON(ctx, "grpcservice", v, []byte("{}"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -315,8 +315,8 @@ func init() {
|
|||||||
return New(ctx, config.(*Config))
|
return New(ctx, config.(*Config))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
common.Must(common.RegisterConfig((*SimplifiedConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
|
common.Must(common.RegisterConfig((*SimplifiedConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { // nolint: staticcheck
|
||||||
ctx = cfgcommon.NewConfigureLoadingContext(context.Background())
|
ctx = cfgcommon.NewConfigureLoadingContext(context.Background()) // nolint: staticcheck
|
||||||
|
|
||||||
geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {
|
geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {
|
||||||
return "standard"
|
return "standard"
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
|
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
|
||||||
|
|
||||||
type InstanceMgr struct {
|
type InstanceMgr struct {
|
||||||
config *Config
|
config *Config // nolint: structcheck
|
||||||
instances map[string]*core.Instance
|
instances map[string]*core.Instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
|
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
|
||||||
|
|
||||||
const (
|
const (
|
||||||
rttFailed = time.Duration(math.MaxInt64 - iota)
|
rttFailed = time.Duration(math.MaxInt64 - iota)
|
||||||
rttUntested
|
rttUntested // nolint: varcheck
|
||||||
rttUnqualified
|
rttUnqualified // nolint: varcheck
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@ type Observer struct {
|
|||||||
config *Config
|
config *Config
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
statusLock sync.Mutex
|
statusLock sync.Mutex // nolint: structcheck
|
||||||
hp *HealthPing
|
hp *HealthPing
|
||||||
|
|
||||||
finished *done.Instance
|
finished *done.Instance
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.27.1
|
// protoc-gen-go v1.27.1
|
||||||
// protoc v3.17.3
|
// protoc v3.17.3
|
||||||
// source: app/observatory/multiObservatory/config.proto
|
// source: app/observatory/multiobservatory/config.proto
|
||||||
|
|
||||||
package multiObservatory
|
package multiobservatory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/v2fly/v2ray-core/v4/common/protoext"
|
_ "github.com/v2fly/v2ray-core/v4/common/protoext"
|
||||||
@ -33,7 +33,7 @@ type Config struct {
|
|||||||
func (x *Config) Reset() {
|
func (x *Config) Reset() {
|
||||||
*x = Config{}
|
*x = Config{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ func (x *Config) String() string {
|
|||||||
func (*Config) ProtoMessage() {}
|
func (*Config) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *Config) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -59,7 +59,7 @@ func (x *Config) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Config.ProtoReflect.Descriptor instead.
|
||||||
func (*Config) Descriptor() ([]byte, []int) {
|
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 {
|
func (x *Config) GetHolders() *taggedfeatures.Config {
|
||||||
@ -69,15 +69,15 @@ func (x *Config) GetHolders() *taggedfeatures.Config {
|
|||||||
return nil
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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 (
|
var (
|
||||||
file_app_observatory_multiObservatory_config_proto_rawDescOnce sync.Once
|
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_rawDescData = file_app_observatory_multiobservatory_config_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_app_observatory_multiObservatory_config_proto_rawDescGZIP() []byte {
|
func file_app_observatory_multiobservatory_config_proto_rawDescGZIP() []byte {
|
||||||
file_app_observatory_multiObservatory_config_proto_rawDescOnce.Do(func() {
|
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)
|
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_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_app_observatory_multiObservatory_config_proto_goTypes = []interface{}{
|
var file_app_observatory_multiobservatory_config_proto_goTypes = []interface{}{
|
||||||
(*Config)(nil), // 0: v2ray.core.app.observatory.multiObservatory.Config
|
(*Config)(nil), // 0: v2ray.core.app.observatory.multiobservatory.Config
|
||||||
(*taggedfeatures.Config)(nil), // 1: v2ray.core.common.taggedfeatures.Config
|
(*taggedfeatures.Config)(nil), // 1: v2ray.core.common.taggedfeatures.Config
|
||||||
}
|
}
|
||||||
var file_app_observatory_multiObservatory_config_proto_depIdxs = []int32{
|
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, // 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 output_type
|
||||||
1, // [1:1] is the sub-list for method input_type
|
1, // [1:1] is the sub-list for method input_type
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
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
|
0, // [0:1] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_app_observatory_multiObservatory_config_proto_init() }
|
func init() { file_app_observatory_multiobservatory_config_proto_init() }
|
||||||
func file_app_observatory_multiObservatory_config_proto_init() {
|
func file_app_observatory_multiobservatory_config_proto_init() {
|
||||||
if File_app_observatory_multiObservatory_config_proto != nil {
|
if File_app_observatory_multiobservatory_config_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
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 {
|
switch v := v.(*Config); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -152,18 +152,18 @@ func file_app_observatory_multiObservatory_config_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_app_observatory_multiObservatory_config_proto_rawDesc,
|
RawDescriptor: file_app_observatory_multiobservatory_config_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 1,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_app_observatory_multiObservatory_config_proto_goTypes,
|
GoTypes: file_app_observatory_multiobservatory_config_proto_goTypes,
|
||||||
DependencyIndexes: file_app_observatory_multiObservatory_config_proto_depIdxs,
|
DependencyIndexes: file_app_observatory_multiobservatory_config_proto_depIdxs,
|
||||||
MessageInfos: file_app_observatory_multiObservatory_config_proto_msgTypes,
|
MessageInfos: file_app_observatory_multiobservatory_config_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_app_observatory_multiObservatory_config_proto = out.File
|
File_app_observatory_multiobservatory_config_proto = out.File
|
||||||
file_app_observatory_multiObservatory_config_proto_rawDesc = nil
|
file_app_observatory_multiobservatory_config_proto_rawDesc = nil
|
||||||
file_app_observatory_multiObservatory_config_proto_goTypes = nil
|
file_app_observatory_multiobservatory_config_proto_goTypes = nil
|
||||||
file_app_observatory_multiObservatory_config_proto_depIdxs = nil
|
file_app_observatory_multiobservatory_config_proto_depIdxs = nil
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package v2ray.core.app.observatory.multiObservatory;
|
package v2ray.core.app.observatory.multiobservatory;
|
||||||
option csharp_namespace = "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_package = "com.v2ray.core.app.observatory.multiObservatory";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import "common/protoext/extensions.proto";
|
|||||||
|
|
||||||
message Config{
|
message Config{
|
||||||
option (v2ray.core.common.protoext.message_opt).type = "service";
|
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 ;
|
v2ray.core.common.taggedfeatures.Config holders = 1 ;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package multiObservatory
|
package multiobservatory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -36,7 +36,7 @@ func New(ctx context.Context, config *Config) (*Observer, error) {
|
|||||||
|
|
||||||
func (x *Config) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes []byte) error {
|
func (x *Config) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes []byte) error {
|
||||||
var err 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package restful_api
|
package restfulapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
174
app/restfulapi/config.pb.go
Normal file
174
app/restfulapi/config.pb.go
Normal 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
|
||||||
|
}
|
@ -2,7 +2,7 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package v2ray.app.restfulapi;
|
package v2ray.app.restfulapi;
|
||||||
option csharp_namespace = "V2Ray.App.Restapi";
|
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_package = "com.v2ray.core.app.restapi";
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ import "common/protoext/extensions.proto";
|
|||||||
|
|
||||||
message Config{
|
message Config{
|
||||||
option (v2ray.core.common.protoext.message_opt).type = "service";
|
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;
|
string listen_addr = 1;
|
||||||
int32 listen_port = 2;
|
int32 listen_port = 2;
|
@ -1,4 +1,4 @@
|
|||||||
package restful_api
|
package restfulapi
|
||||||
|
|
||||||
import "github.com/v2fly/v2ray-core/v4/common/errors"
|
import "github.com/v2fly/v2ray-core/v4/common/errors"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package restful_api
|
package restfulapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package restful_api
|
package restfulapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package restful_api
|
package restfulapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
@ -178,7 +178,7 @@ func (br *BalancingRule) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes
|
|||||||
if stub.Strategy == "" {
|
if stub.Strategy == "" {
|
||||||
stub.Strategy = "random"
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,6 @@ func init() {
|
|||||||
var routingRules []*RoutingRule
|
var routingRules []*RoutingRule
|
||||||
|
|
||||||
for _, v := range simplifiedConfig.Rule {
|
for _, v := range simplifiedConfig.Rule {
|
||||||
|
|
||||||
rule := new(RoutingRule)
|
rule := new(RoutingRule)
|
||||||
|
|
||||||
for _, geo := range v.Geoip {
|
for _, geo := range v.Geoip {
|
||||||
|
@ -64,8 +64,8 @@ func (l *LeastLoadStrategy) InjectContext(ctx context.Context) {
|
|||||||
l.ctx = ctx
|
l.ctx = ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeastLoadStrategy) PickOutbound(candidates []string) string {
|
func (l *LeastLoadStrategy) PickOutbound(candidates []string) string {
|
||||||
selects := s.pickOutbounds(candidates)
|
selects := l.pickOutbounds(candidates)
|
||||||
count := len(selects)
|
count := len(selects)
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
// goes to fallbackTag
|
// goes to fallbackTag
|
||||||
@ -74,9 +74,9 @@ func (s *LeastLoadStrategy) PickOutbound(candidates []string) string {
|
|||||||
return selects[dice.Roll(count)].Tag
|
return selects[dice.Roll(count)].Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeastLoadStrategy) pickOutbounds(candidates []string) []*node {
|
func (l *LeastLoadStrategy) pickOutbounds(candidates []string) []*node {
|
||||||
qualified := s.getNodes(candidates, time.Duration(s.settings.MaxRTT))
|
qualified := l.getNodes(candidates, time.Duration(l.settings.MaxRTT))
|
||||||
selects := s.selectLeastLoad(qualified)
|
selects := l.selectLeastLoad(qualified)
|
||||||
return selects
|
return selects
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +96,12 @@ func (s *LeastLoadStrategy) pickOutbounds(candidates []string) []*node {
|
|||||||
// 3. Speed priority: Baselines + `Expected Count <= 0`.
|
// 3. Speed priority: Baselines + `Expected Count <= 0`.
|
||||||
// go through all baselines until find selects, if not, select none. Used in combination
|
// 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.
|
// 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 {
|
if len(nodes) == 0 {
|
||||||
newError("least load: no qualified outbound").AtInfo().WriteToLog()
|
newError("least load: no qualified outbound").AtInfo().WriteToLog()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
expected := int(s.settings.Expected)
|
expected := int(l.settings.Expected)
|
||||||
availableCount := len(nodes)
|
availableCount := len(nodes)
|
||||||
if expected > availableCount {
|
if expected > availableCount {
|
||||||
return nodes
|
return nodes
|
||||||
@ -110,13 +110,13 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
|
|||||||
if expected <= 0 {
|
if expected <= 0 {
|
||||||
expected = 1
|
expected = 1
|
||||||
}
|
}
|
||||||
if len(s.settings.Baselines) == 0 {
|
if len(l.settings.Baselines) == 0 {
|
||||||
return nodes[:expected]
|
return nodes[:expected]
|
||||||
}
|
}
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
// go through all base line until find expected selects
|
// 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)
|
baseline := time.Duration(b)
|
||||||
for i := 0; i < availableCount; i++ {
|
for i := 0; i < availableCount; i++ {
|
||||||
if nodes[i].RTTDeviationCost > baseline {
|
if nodes[i].RTTDeviationCost > baseline {
|
||||||
@ -130,30 +130,30 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.settings.Expected > 0 && count < expected {
|
if l.settings.Expected > 0 && count < expected {
|
||||||
count = expected
|
count = expected
|
||||||
}
|
}
|
||||||
return nodes[:count]
|
return nodes[:count]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node {
|
func (l *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node {
|
||||||
if s.observer == nil {
|
if l.observer == nil {
|
||||||
common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error {
|
common.Must(core.RequireFeatures(l.ctx, func(observatory extension.Observatory) error {
|
||||||
s.observer = observatory
|
l.observer = observatory
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
var result proto.Message
|
var result proto.Message
|
||||||
if s.settings.ObserverTag == "" {
|
if l.settings.ObserverTag == "" {
|
||||||
observeResult, err := s.observer.GetObservation(s.ctx)
|
observeResult, err := l.observer.GetObservation(l.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError("cannot get observation").Base(err).WriteToLog()
|
newError("cannot get observation").Base(err).WriteToLog()
|
||||||
return make([]*node, 0)
|
return make([]*node, 0)
|
||||||
}
|
}
|
||||||
result = observeResult
|
result = observeResult
|
||||||
} else {
|
} 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 {
|
if err != nil {
|
||||||
newError("cannot get observation").Base(err).WriteToLog()
|
newError("cannot get observation").Base(err).WriteToLog()
|
||||||
return make([]*node, 0)
|
return make([]*node, 0)
|
||||||
@ -175,16 +175,15 @@ func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration)
|
|||||||
CountFail: 1,
|
CountFail: 1,
|
||||||
RTTAverage: time.Duration(v.Delay) * time.Millisecond,
|
RTTAverage: time.Duration(v.Delay) * time.Millisecond,
|
||||||
RTTDeviation: 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 {
|
if v.HealthPing != nil {
|
||||||
record.RTTAverage = time.Duration(v.HealthPing.Average)
|
record.RTTAverage = time.Duration(v.HealthPing.Average)
|
||||||
record.RTTDeviation = time.Duration(v.HealthPing.Deviation)
|
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.CountAll = int(v.HealthPing.All)
|
||||||
record.CountFail = int(v.HealthPing.Fail)
|
record.CountFail = int(v.HealthPing.Fail)
|
||||||
|
|
||||||
}
|
}
|
||||||
ret = append(ret, record)
|
ret = append(ret, record)
|
||||||
}
|
}
|
||||||
|
@ -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
|
// LoadArgToBytes loads one arg to []byte, maybe an remote url, or local file path
|
||||||
func LoadArgToBytes(arg string) (out []byte, err error) {
|
func LoadArgToBytes(arg string) (out []byte, err error) {
|
||||||
switch {
|
out, err = ioutil.ReadFile(arg)
|
||||||
default:
|
|
||||||
out, err = ioutil.ReadFile(arg)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,5 @@ func ContextWithEnvironment(ctx context.Context, environment interface{}) contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
func EnvironmentFromContext(ctx context.Context) interface{} {
|
func EnvironmentFromContext(ctx context.Context) interface{} {
|
||||||
if environment, ok := ctx.Value(environmentKey).(interface{}); ok {
|
return ctx.Value(environmentKey)
|
||||||
return environment
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func ParseNetwork(net string) Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ParseNetworks(netlist string) []Network {
|
func ParseNetworks(netlist string) []Network {
|
||||||
strlist := strings.Split(string(netlist), ",")
|
strlist := strings.Split(netlist, ",")
|
||||||
nl := make([]Network, len(strlist))
|
nl := make([]Network, len(strlist))
|
||||||
for idx, network := range strlist {
|
for idx, network := range strlist {
|
||||||
nl[idx] = ParseNetwork(network)
|
nl[idx] = ParseNetwork(network)
|
||||||
|
@ -10,22 +10,18 @@ import (
|
|||||||
|
|
||||||
func GetMessageOptions(msgDesc protoreflect.MessageDescriptor) (*MessageOpt, error) {
|
func GetMessageOptions(msgDesc protoreflect.MessageDescriptor) (*MessageOpt, error) {
|
||||||
msgOpt := msgDesc.Options().(*descriptorpb.MessageOptions)
|
msgOpt := msgDesc.Options().(*descriptorpb.MessageOptions)
|
||||||
var V2MessageOption *MessageOpt
|
msgOptRet, err := proto.GetExtension(msgOpt, E_MessageOpt)
|
||||||
if msgOptRet, err := proto.GetExtension(msgOpt, E_MessageOpt); err != nil {
|
if err != nil {
|
||||||
return nil, newError("unable to parse extension from message").Base(err)
|
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) {
|
func GetFieldOptions(fieldDesc protoreflect.FieldDescriptor) (*FieldOpt, error) {
|
||||||
fieldOpt := fieldDesc.Options().(*descriptorpb.FieldOptions)
|
fieldOpt := fieldDesc.Options().(*descriptorpb.FieldOptions)
|
||||||
var V2FieldOption *FieldOpt
|
msgOptRet, err := proto.GetExtension(fieldOpt, E_FieldOpt)
|
||||||
if msgOptRet, err := proto.GetExtension(fieldOpt, E_FieldOpt); err != nil {
|
if err != nil {
|
||||||
return nil, newError("unable to parse extension from message").Base(err)
|
return nil, newError("unable to parse extension from message").Base(err)
|
||||||
} else {
|
|
||||||
V2FieldOption = msgOptRet.(*FieldOpt)
|
|
||||||
}
|
}
|
||||||
return V2FieldOption, nil
|
return msgOptRet.(*FieldOpt), nil
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,7 @@ func filterMessage(ctx context.Context, message protoreflect.Message) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v2extension.ConvertTimeParseIp != "" {
|
if v2extension.ConvertTimeParseIp != "" {
|
||||||
strIp := value.String()
|
ipValue := net.ParseIP(value.String())
|
||||||
ipValue := net.ParseIP(strIp)
|
|
||||||
target := message.Descriptor().Fields().ByTextName(v2extension.ConvertTimeParseIp)
|
target := message.Descriptor().Fields().ByTextName(v2extension.ConvertTimeParseIp)
|
||||||
pendingWriteQueue = append(pendingWriteQueue, pendingWrite{
|
pendingWriteQueue = append(pendingWriteQueue, pendingWrite{
|
||||||
field: target,
|
field: target,
|
||||||
@ -116,10 +115,7 @@ func filterMap(ctx context.Context, mapValue protoreflect.Map) error {
|
|||||||
var err error
|
var err error
|
||||||
mapValue.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
mapValue.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||||
err = filterMessage(ctx, value.Message())
|
err = filterMessage(ctx, value.Message())
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ const (
|
|||||||
muxPreferedSessionKey
|
muxPreferedSessionKey
|
||||||
sockoptSessionKey
|
sockoptSessionKey
|
||||||
trackedConnectionErrorKey
|
trackedConnectionErrorKey
|
||||||
handlerSessionKey
|
handlerSessionKey // nolint: varcheck
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContextWithID returns a new context with the given ID.
|
// ContextWithID returns a new context with the given ID.
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/v5cfg"
|
"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 {
|
type ItemStub struct {
|
||||||
MemberType string `json:"type"`
|
MemberType string `json:"type"`
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
@ -27,7 +27,7 @@ func LoadJsonConfig(ctx context.Context, interfaceType, defaultImpl string, mess
|
|||||||
if v.MemberType == "" {
|
if v.MemberType == "" {
|
||||||
v.MemberType = defaultImpl
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -154,9 +154,8 @@ func loadSingleConfigAutoFormat(input interface{}) (*Config, error) {
|
|||||||
c, err := f.Loader(input)
|
c, err := f.Loader(input)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return c, 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()
|
return nil, newError("tried all loaders but failed when attempting to parse: ", input, ";", errorReasons.String()).AtWarning()
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,5 @@ func mapToJSON(tree *toml.Tree) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return string(bytes[:]), nil
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
|
//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{}
|
coreconf := &core.Config{}
|
||||||
jsonpbloader := &jsonpb.Unmarshaler{AnyResolver: serial.GetResolver()}
|
jsonpbloader := &jsonpb.Unmarshaler{AnyResolver: serial.GetResolver()}
|
||||||
err := jsonpbloader.Unmarshal(data, coreconf)
|
err := jsonpbloader.Unmarshal(data, coreconf)
|
||||||
@ -26,7 +26,7 @@ func loadJsonPb(data io.Reader) (*core.Config, error) {
|
|||||||
return coreconf, nil
|
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()}
|
jsonpbdumper := &jsonpb.Marshaler{AnyResolver: serial.GetResolver()}
|
||||||
err := jsonpbdumper.Marshal(w, config)
|
err := jsonpbdumper.Marshal(w, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -35,8 +35,8 @@ func dumpJsonPb(config proto.Message, w io.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DumpJsonPb(config proto.Message, w io.Writer) error {
|
func DumpJSONPb(config proto.Message, w io.Writer) error {
|
||||||
return dumpJsonPb(config, w)
|
return dumpJSONPb(config, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormatProtobufJSONPB = "jsonpb"
|
const FormatProtobufJSONPB = "jsonpb"
|
||||||
@ -56,13 +56,13 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return loadJsonPb(bytes.NewReader(data))
|
return loadJSONPB(bytes.NewReader(data))
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
data, err := buf.ReadAllToBytes(v)
|
data, err := buf.ReadAllToBytes(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return loadJsonPb(bytes.NewReader(data))
|
return loadJSONPB(bytes.NewReader(data))
|
||||||
default:
|
default:
|
||||||
return nil, newError("unknow type")
|
return nil, newError("unknow type")
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
core "github.com/v2fly/v2ray-core/v4"
|
core "github.com/v2fly/v2ray-core/v4"
|
||||||
"github.com/v2fly/v2ray-core/v4/common/errors"
|
"github.com/v2fly/v2ray-core/v4/common/errors"
|
||||||
json_reader "github.com/v2fly/v2ray-core/v4/infra/conf/json"
|
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 {
|
type offset struct {
|
||||||
|
@ -139,7 +139,7 @@ var typeMap = map[routercommon.Domain_Type]dns.DomainMatchingType{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DNSConfig is a JSON serializable object for dns.Config.
|
// DNSConfig is a JSON serializable object for dns.Config.
|
||||||
type DNSConfig struct {
|
type DNSConfig struct { // nolint: revive
|
||||||
Servers []*NameServerConfig `json:"servers"`
|
Servers []*NameServerConfig `json:"servers"`
|
||||||
Hosts map[string]*HostAddress `json:"hosts"`
|
Hosts map[string]*HostAddress `json:"hosts"`
|
||||||
ClientIP *cfgcommon.Address `json:"clientIp"`
|
ClientIP *cfgcommon.Address `json:"clientIp"`
|
||||||
@ -216,7 +216,6 @@ func (c *DNSConfig) Build() (*dns.Config, error) {
|
|||||||
} else {
|
} else {
|
||||||
return nil, newError("unable to create geo data loader ").Base(err)
|
return nil, newError("unable to create geo data loader ").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgEnv := cfgcommon.GetConfigureLoadingEnvironment(c.cfgctx)
|
cfgEnv := cfgcommon.GetConfigureLoadingEnvironment(c.cfgctx)
|
||||||
|
@ -14,7 +14,7 @@ func DefaultLogConfig() *log.Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogConfig struct {
|
type LogConfig struct { // nolint: revive
|
||||||
AccessLog string `json:"access"`
|
AccessLog string `json:"access"`
|
||||||
ErrorLog string `json:"error"`
|
ErrorLog string `json:"error"`
|
||||||
LogLevel string `json:"loglevel"`
|
LogLevel string `json:"loglevel"`
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
rule2 "github.com/v2fly/v2ray-core/v4/infra/conf/rule"
|
rule2 "github.com/v2fly/v2ray-core/v4/infra/conf/rule"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RouterRulesConfig struct {
|
type RouterRulesConfig struct { // nolint: revive
|
||||||
RuleList []json.RawMessage `json:"rules"`
|
RuleList []json.RawMessage `json:"rules"`
|
||||||
DomainStrategy string `json:"domainStrategy"`
|
DomainStrategy string `json:"domainStrategy"`
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type RouterConfig struct {
|
type RouterConfig struct { // nolint: revive
|
||||||
Settings *RouterRulesConfig `json:"settings"` // Deprecated
|
Settings *RouterRulesConfig `json:"settings"` // Deprecated
|
||||||
RuleList []json.RawMessage `json:"rules"`
|
RuleList []json.RawMessage `json:"rules"`
|
||||||
DomainStrategy *string `json:"domainStrategy"`
|
DomainStrategy *string `json:"domainStrategy"`
|
||||||
|
@ -89,18 +89,18 @@ func (v *V2JsonProtobufFollower) Clear(descriptor protoreflect.FieldDescriptor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *V2JsonProtobufFollower) Set(descriptor protoreflect.FieldDescriptor, value protoreflect.Value) {
|
func (v *V2JsonProtobufFollower) Set(descriptor protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||||
switch descriptor.(type) {
|
switch descriptor := descriptor.(type) {
|
||||||
case V2JsonProtobufFollowerFieldDescriptor:
|
case V2JsonProtobufFollowerFieldDescriptor:
|
||||||
v.Message.Set(descriptor.(V2JsonProtobufFollowerFieldDescriptor).FieldDescriptor, value)
|
v.Message.Set(descriptor.FieldDescriptor, value)
|
||||||
case *V2JsonProtobufFollowerFieldDescriptor:
|
case *V2JsonProtobufFollowerFieldDescriptor:
|
||||||
v.Message.Set(descriptor.(*V2JsonProtobufFollowerFieldDescriptor).FieldDescriptor, value)
|
v.Message.Set(descriptor.FieldDescriptor, value)
|
||||||
case *V2JsonProtobufAnyValueField:
|
case *V2JsonProtobufAnyValueField:
|
||||||
protodata := value.Message()
|
protodata := value.Message()
|
||||||
bytesw, err := proto.MarshalOptions{AllowPartial: true}.Marshal(&V2JsonProtobufAnyValueFieldReturn{protodata})
|
bytesw, err := proto.MarshalOptions{AllowPartial: true}.Marshal(&V2JsonProtobufAnyValueFieldReturn{protodata})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
v.Message.Set(descriptor.(*V2JsonProtobufAnyValueField).FieldDescriptor, protoreflect.ValueOfBytes(bytesw))
|
v.Message.Set(descriptor.FieldDescriptor, protoreflect.ValueOfBytes(bytesw))
|
||||||
default:
|
default:
|
||||||
v.Message.Set(descriptor, value)
|
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 {
|
func (v *V2JsonProtobufFollower) NewField(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
if _, ok := descriptor.(*V2JsonProtobufAnyValueField); ok {
|
if _, ok := descriptor.(*V2JsonProtobufAnyValueField); ok {
|
||||||
|
|
||||||
url := v.Message.Get(v.Message.Descriptor().Fields().ByName("type_url")).String()
|
url := v.Message.Get(v.Message.Descriptor().Fields().ByName("type_url")).String()
|
||||||
|
|
||||||
v2type := serial.V2TypeFromURL(url)
|
v2type := serial.V2TypeFromURL(url)
|
||||||
instance, err := serial.GetInstance(v2type)
|
instance, err := serial.GetInstance(v2type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/net"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
"github.com/v2fly/v2ray-core/v4/proxy/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/net"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
"github.com/v2fly/v2ray-core/v4/proxy/dokodemo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/protocol"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
|
"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/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"
|
"github.com/v2fly/v2ray-core/v4/proxy/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v4/app/observatory"
|
"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/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/serial"
|
||||||
"github.com/v2fly/v2ray-core/v4/common/taggedfeatures"
|
"github.com/v2fly/v2ray-core/v4/common/taggedfeatures"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/duration"
|
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/duration"
|
||||||
@ -32,11 +32,11 @@ type BurstObservatoryConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b BurstObservatoryConfig) Build() (proto.Message, error) {
|
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
|
return &burst.Config{SubjectSelector: b.SubjectSelector, PingConfig: result.(*burst.HealthPingConfig)}, nil
|
||||||
} else {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiObservatoryItem struct {
|
type MultiObservatoryItem struct {
|
||||||
@ -50,7 +50,7 @@ type MultiObservatoryConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *MultiObservatoryConfig) Build() (proto.Message, error) {
|
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 {
|
for _, v := range o.Observers {
|
||||||
switch v.MemberType {
|
switch v.MemberType {
|
||||||
case "burst":
|
case "burst":
|
||||||
@ -64,7 +64,6 @@ func (o *MultiObservatoryConfig) Build() (proto.Message, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ret.Holders.Features[v.Tag] = serial.ToTypedMessage(burstObservatoryConfigPb)
|
ret.Holders.Features[v.Tag] = serial.ToTypedMessage(burstObservatoryConfigPb)
|
||||||
break
|
|
||||||
case "default":
|
case "default":
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/v2fly/v2ray-core/v4/common"
|
"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) {
|
func TestBufferSize(t *testing.T) {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/app/reverse"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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) {
|
func TestReverseConfig(t *testing.T) {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
"github.com/v2fly/v2ray-core/v4/proxy/shadowsocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
"github.com/v2fly/v2ray-core/v4/proxy/socks"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"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/socketcfg"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
||||||
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/http"
|
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/http"
|
||||||
|
@ -471,7 +471,7 @@ func (c *Config) Build() (*core.Config, error) {
|
|||||||
" instead of allowing end user to enable it without special tool and knowledge.")
|
" instead of allowing end user to enable it without special tool and knowledge.")
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
return nil, newError("Cannot load service").Base(developererr).Base(err).Base(newError(sb.String()))
|
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
|
// Using a else here is required to keep msg in scope
|
||||||
config.App = append(config.App, msg...)
|
config.App = append(config.App, msg...)
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
// Geo loaders
|
// Geo loaders
|
||||||
_ "github.com/v2fly/v2ray-core/v4/infra/conf/geodata/memconservative"
|
_ "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/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"
|
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
|
||||||
dns_proxy "github.com/v2fly/v2ray-core/v4/proxy/dns"
|
dns_proxy "github.com/v2fly/v2ray-core/v4/proxy/dns"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
|
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/vless/inbound"
|
"github.com/v2fly/v2ray-core/v4/proxy/vless/inbound"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/vless/outbound"
|
"github.com/v2fly/v2ray-core/v4/proxy/vless/outbound"
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/testassist"
|
"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"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound"
|
"github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/vmess/outbound"
|
"github.com/v2fly/v2ray-core/v4/proxy/vmess/outbound"
|
||||||
|
@ -11,16 +11,16 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/registry"
|
"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()
|
fsdef := envimpl.NewDefaultFileSystemDefaultImpl()
|
||||||
ctx := envctx.ContextWithEnvironment(context.TODO(), fsdef)
|
ctx := envctx.ContextWithEnvironment(context.TODO(), fsdef)
|
||||||
if rawJson == nil || len(rawJson) == 0 {
|
if rawJSON == nil || len(rawJSON) == 0 {
|
||||||
rawJson = []byte("{}")
|
rawJSON = []byte("{}")
|
||||||
}
|
}
|
||||||
return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJson))
|
return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJSON))
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadHeterogeneousConfigFromRawJson private API
|
// LoadHeterogeneousConfigFromRawJSON private API
|
||||||
func LoadHeterogeneousConfigFromRawJson(ctx context.Context, interfaceType, name string, rawJson json.RawMessage) (proto.Message, error) {
|
func LoadHeterogeneousConfigFromRawJSON(ctx context.Context, interfaceType, name string, rawJSON json.RawMessage) (proto.Message, error) {
|
||||||
return loadHeterogeneousConfigFromRawJson(interfaceType, name, rawJson)
|
return loadHeterogeneousConfigFromRawJSON(interfaceType, name, rawJSON)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func (c InboundConfig) BuildV5(ctx context.Context) (proto.Message, error) {
|
|||||||
c.Settings = []byte("{}")
|
c.Settings = []byte("{}")
|
||||||
}
|
}
|
||||||
|
|
||||||
inboundConfigPack, err := loadHeterogeneousConfigFromRawJson("inbound", c.Protocol, c.Settings)
|
inboundConfigPack, err := loadHeterogeneousConfigFromRawJSON("inbound", c.Protocol, c.Settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("unable to load inbound protocol config").Base(err)
|
return nil, newError("unable to load inbound protocol config").Base(err)
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return loadJsonConfig(data)
|
return loadJSONConfig(data)
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
data, err := buf.ReadAllToBytes(v)
|
data, err := buf.ReadAllToBytes(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return loadJsonConfig(data)
|
return loadJSONConfig(data)
|
||||||
default:
|
default:
|
||||||
return nil, newError("unknown type")
|
return nil, newError("unknown type")
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func (c OutboundConfig) BuildV5(ctx context.Context) (proto.Message, error) {
|
|||||||
c.Settings = []byte("{}")
|
c.Settings = []byte("{}")
|
||||||
}
|
}
|
||||||
|
|
||||||
outboundConfigPack, err := loadHeterogeneousConfigFromRawJson("outbound", c.Protocol, c.Settings)
|
outboundConfigPack, err := loadHeterogeneousConfigFromRawJSON("outbound", c.Protocol, c.Settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("unable to load outbound protocol config").Base(err)
|
return nil, newError("unable to load outbound protocol config").Base(err)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
|
|||||||
|
|
||||||
var logConfMsg *anypb.Any
|
var logConfMsg *anypb.Any
|
||||||
if c.LogConfig != nil {
|
if c.LogConfig != nil {
|
||||||
logConfMsgUnpacked, err := loadHeterogeneousConfigFromRawJson("service", "log", c.LogConfig)
|
logConfMsgUnpacked, err := loadHeterogeneousConfigFromRawJSON("service", "log", c.LogConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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...)
|
config.App = append([]*anypb.Any{logConfMsg}, config.App...)
|
||||||
|
|
||||||
if c.RouterConfig != nil {
|
if c.RouterConfig != nil {
|
||||||
routerConfig, err := loadHeterogeneousConfigFromRawJson("service", "router", c.RouterConfig)
|
routerConfig, err := loadHeterogeneousConfigFromRawJSON("service", "router", c.RouterConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.DNSConfig != nil {
|
if c.DNSConfig != nil {
|
||||||
dnsApp, err := loadHeterogeneousConfigFromRawJson("service", "dns", c.DNSConfig)
|
dnsApp, err := loadHeterogeneousConfigFromRawJSON("service", "dns", c.DNSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("failed to parse DNS config").Base(err)
|
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 {
|
for serviceName, service := range c.Services {
|
||||||
servicePackedConfig, err := loadHeterogeneousConfigFromRawJson("service", serviceName, service)
|
servicePackedConfig, err := loadHeterogeneousConfigFromRawJSON("service", serviceName, service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ func (c RootConfig) BuildV5(ctx context.Context) (proto.Message, error) {
|
|||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadJsonConfig(data []byte) (*core.Config, error) {
|
func loadJSONConfig(data []byte) (*core.Config, error) {
|
||||||
rootConfig := &RootConfig{}
|
rootConfig := &RootConfig{}
|
||||||
|
|
||||||
err := json.Unmarshal(data, rootConfig)
|
err := json.Unmarshal(data, rootConfig)
|
||||||
|
@ -22,7 +22,7 @@ func (s StreamConfig) BuildV5(ctx context.Context) (proto.Message, error) {
|
|||||||
if s.TransportSettings == nil {
|
if s.TransportSettings == nil {
|
||||||
s.TransportSettings = []byte("{}")
|
s.TransportSettings = []byte("{}")
|
||||||
}
|
}
|
||||||
transportConfigPack, err := loadHeterogeneousConfigFromRawJson("transport", s.Transport, s.TransportSettings)
|
transportConfigPack, err := loadHeterogeneousConfigFromRawJSON("transport", s.Transport, s.TransportSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("unable to load transport config").Base(err)
|
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 {
|
if s.SecuritySettings == nil {
|
||||||
s.SecuritySettings = []byte("{}")
|
s.SecuritySettings = []byte("{}")
|
||||||
}
|
}
|
||||||
securityConfigPack, err := loadHeterogeneousConfigFromRawJson("security", s.Security, s.SecuritySettings)
|
securityConfigPack, err := loadHeterogeneousConfigFromRawJSON("security", s.Security, s.SecuritySettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError("unable to load security config").Base(err)
|
return nil, newError("unable to load security config").Base(err)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func dialAPIServerWithContext(ctx context.Context) (conn *grpc.ClientConn) {
|
|||||||
return
|
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
|
return strings.TrimSpace(protojson.MarshalOptions{Indent: indent}.Format(m)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,9 @@ var cmdConvertPb = &base.Command{
|
|||||||
if len(configFiles) == 0 {
|
if len(configFiles) == 0 {
|
||||||
base.Fatalf("%s", newError("failed to load config").Base(err))
|
base.Fatalf("%s", newError("failed to load config").Base(err))
|
||||||
return
|
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)
|
bytew, err := proto.Marshal(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,7 +31,7 @@ var cmdReversePb = &base.Command{
|
|||||||
}
|
}
|
||||||
switch *configFormat {
|
switch *configFormat {
|
||||||
case "jsonpb":
|
case "jsonpb":
|
||||||
if err := jsonpb.DumpJsonPb(&conf, os.Stdout); err != nil {
|
if err := jsonpb.DumpJSONPb(&conf, os.Stdout); err != nil {
|
||||||
base.Fatalf("%s", err)
|
base.Fatalf("%s", err)
|
||||||
}
|
}
|
||||||
case "v2jsonpb":
|
case "v2jsonpb":
|
||||||
|
@ -136,7 +136,7 @@ func executeConvert(cmd *base.Command, args []string) {
|
|||||||
base.Fatalf(err.Error())
|
base.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
w := bytes.NewBuffer(nil)
|
w := bytes.NewBuffer(nil)
|
||||||
err = jsonpb.DumpJsonPb(pbConfig, w)
|
err = jsonpb.DumpJSONPb(pbConfig, w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Fatalf(err.Error())
|
base.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/merge"
|
"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/mergers"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
|
"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:
|
// LoadConfig load config files to *conf.Config, it will:
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
// Developer preview features
|
// Developer preview features
|
||||||
_ "github.com/v2fly/v2ray-core/v4/app/instman"
|
_ "github.com/v2fly/v2ray-core/v4/app/instman"
|
||||||
_ "github.com/v2fly/v2ray-core/v4/app/observatory"
|
_ "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.
|
// Inbound and outbound proxies.
|
||||||
_ "github.com/v2fly/v2ray-core/v4/proxy/blackhole"
|
_ "github.com/v2fly/v2ray-core/v4/proxy/blackhole"
|
||||||
@ -89,6 +89,7 @@ import (
|
|||||||
// V5 version of json configure file parser
|
// V5 version of json configure file parser
|
||||||
_ "github.com/v2fly/v2ray-core/v4/infra/conf/v5cfg"
|
_ "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/http/simplified"
|
||||||
_ "github.com/v2fly/v2ray-core/v4/proxy/shadowsocks/simplified"
|
_ "github.com/v2fly/v2ray-core/v4/proxy/shadowsocks/simplified"
|
||||||
_ "github.com/v2fly/v2ray-core/v4/proxy/socks/simplified"
|
_ "github.com/v2fly/v2ray-core/v4/proxy/socks/simplified"
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/app/router"
|
"github.com/v2fly/v2ray-core/v4/app/router"
|
||||||
"github.com/v2fly/v2ray-core/v4/common/net"
|
"github.com/v2fly/v2ray-core/v4/common/net"
|
||||||
"github.com/v2fly/v2ray-core/v4/common/serial"
|
"github.com/v2fly/v2ray-core/v4/common/serial"
|
||||||
|
|
||||||
|
// Initialization
|
||||||
_ "github.com/v2fly/v2ray-core/v4/main/distro/all"
|
_ "github.com/v2fly/v2ray-core/v4/main/distro/all"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
|
"github.com/v2fly/v2ray-core/v4/proxy/blackhole"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/dokodemo"
|
"github.com/v2fly/v2ray-core/v4/proxy/dokodemo"
|
||||||
@ -77,7 +79,6 @@ func (b *bindingInstance) startAPIInstance() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
b.instance = instance
|
b.instance = instance
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func withDefaultApps(config *core.Config) *core.Config {
|
func withDefaultApps(config *core.Config) *core.Config {
|
||||||
|
@ -146,7 +146,7 @@ func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, e
|
|||||||
iv = make([]byte, account.Cipher.IVSize())
|
iv = make([]byte, account.Cipher.IVSize())
|
||||||
if n, err := io.ReadFull(reader, iv); err != nil {
|
if n, err := io.ReadFull(reader, iv); err != nil {
|
||||||
return nil, newError("failed to read IV").Base(err)
|
return nil, newError("failed to read IV").Base(err)
|
||||||
} else { // nolint: golint
|
} else { // nolint: revive
|
||||||
drainer.AcknowledgeReceive(n)
|
drainer.AcknowledgeReceive(n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,12 +239,12 @@ func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon
|
|||||||
if n, err := io.ReadFull(reader, aeadEncryptedResponseHeaderLength[:]); err != nil {
|
if n, err := io.ReadFull(reader, aeadEncryptedResponseHeaderLength[:]); err != nil {
|
||||||
c.readDrainer.AcknowledgeReceive(n)
|
c.readDrainer.AcknowledgeReceive(n)
|
||||||
return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Len").Base(err))
|
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)
|
c.readDrainer.AcknowledgeReceive(n)
|
||||||
}
|
}
|
||||||
if decryptedResponseHeaderLengthBinaryBuffer, err := aeadResponseHeaderLengthEncryptionAEAD.Open(nil, aeadResponseHeaderLengthEncryptionIV, aeadEncryptedResponseHeaderLength[:], nil); err != nil {
|
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))
|
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))
|
common.Must(binary.Read(bytes.NewReader(decryptedResponseHeaderLengthBinaryBuffer), binary.BigEndian, &decryptedResponseHeaderLengthBinaryDeserializeBuffer))
|
||||||
decryptedResponseHeaderLength = int(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 {
|
if n, err := io.ReadFull(reader, encryptedResponseHeaderBuffer); err != nil {
|
||||||
c.readDrainer.AcknowledgeReceive(n)
|
c.readDrainer.AcknowledgeReceive(n)
|
||||||
return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Data").Base(err))
|
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)
|
c.readDrainer.AcknowledgeReceive(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if decryptedResponseHeaderBuffer, err := aeadResponseHeaderPayloadEncryptionAEAD.Open(nil, aeadResponseHeaderPayloadEncryptionIV, encryptedResponseHeaderBuffer, nil); err != nil {
|
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))
|
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)
|
c.responseReader = bytes.NewReader(decryptedResponseHeaderBuffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ func (h *HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
|
|||||||
// Parse the request
|
// Parse the request
|
||||||
if req, err := readRequest(bufio.NewReader(bytes.NewReader(headerBuf.Bytes()))); err != nil {
|
if req, err := readRequest(bufio.NewReader(bytes.NewReader(headerBuf.Bytes()))); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else { // nolint: golint
|
} else { // nolint: revive
|
||||||
h.req = req
|
h.req = req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ type PacketWriter interface {
|
|||||||
io.Writer
|
io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
type KCPPacketReader struct { // nolint: golint
|
type KCPPacketReader struct { // nolint: revive
|
||||||
Security cipher.AEAD
|
Security cipher.AEAD
|
||||||
Header internet.PacketHeader
|
Header internet.PacketHeader
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ func (r *KCPPacketReader) Read(b []byte) []Segment {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
type KCPPacketWriter struct { // nolint: golint
|
type KCPPacketWriter struct { // nolint: revive
|
||||||
Header internet.PacketHeader
|
Header internet.PacketHeader
|
||||||
Security cipher.AEAD
|
Security cipher.AEAD
|
||||||
Writer io.Writer
|
Writer io.Writer
|
||||||
|
@ -6,11 +6,11 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// TCP_FASTOPEN is the socket option on darwin for TCP fast open.
|
// 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 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 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 {
|
func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// For incoming connections.
|
// For incoming connections.
|
||||||
TCP_FASTOPEN = 23 // nolint: golint,stylecheck
|
TCP_FASTOPEN = 23 // nolint: revive,stylecheck
|
||||||
// For out-going connections.
|
// 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 {
|
func bindAddr(fd uintptr, ip []byte, port uint32) error {
|
||||||
|
@ -3,7 +3,7 @@ package internet
|
|||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TCP_FASTOPEN = 15 // nolint: golint,stylecheck
|
TCP_FASTOPEN = 15 // nolint: revive,stylecheck
|
||||||
)
|
)
|
||||||
|
|
||||||
func setTFO(fd syscall.Handle, settings SocketConfig_TCPFastOpenState) error {
|
func setTFO(fd syscall.Handle, settings SocketConfig_TCPFastOpenState) error {
|
||||||
|
@ -70,7 +70,7 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ctx = context.WithValue(ctx, address, locker) // nolint: golint,staticcheck
|
ctx = context.WithValue(ctx, address, locker) // nolint: revive,staticcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
"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) {
|
func GetOriginalDestination(conn internet.Connection) (net.Destination, error) {
|
||||||
sysrawconn, f := conn.(syscall.Conn)
|
sysrawconn, f := conn.(syscall.Conn)
|
||||||
|
Loading…
Reference in New Issue
Block a user