diff --git a/app/dns/server.go b/app/dns/server.go index 2a42f451..b1e63161 100644 --- a/app/dns/server.go +++ b/app/dns/server.go @@ -8,9 +8,9 @@ import ( "v2ray.com/core/app" "v2ray.com/core/app/dispatcher" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "github.com/miekg/dns" ) @@ -125,5 +125,5 @@ func (v CacheServerFactory) AppId() app.ID { } func init() { - app.RegisterApplicationFactory(loader.GetType(new(Config)), CacheServerFactory{}) + app.RegisterApplicationFactory(serial.GetMessageType(new(Config)), CacheServerFactory{}) } diff --git a/app/router/router.go b/app/router/router.go index 6bae8df6..0752b898 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -4,9 +4,9 @@ import ( "v2ray.com/core/app" "v2ray.com/core/app/dns" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy" ) @@ -125,5 +125,5 @@ func (RouterFactory) AppId() app.ID { } func init() { - app.RegisterApplicationFactory(loader.GetType(new(Config)), RouterFactory{}) + app.RegisterApplicationFactory(serial.GetMessageType(new(Config)), RouterFactory{}) } diff --git a/app/web/config.pb.go b/app/web/config.pb.go index 1dd5b754..0ca865a7 100644 --- a/app/web/config.pb.go +++ b/app/web/config.pb.go @@ -18,7 +18,7 @@ package web import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -162,8 +162,8 @@ func _FileServer_Entry_OneofSizer(msg proto.Message) (n int) { } type Server struct { - Domain []string `protobuf:"bytes,1,rep,name=domain" json:"domain,omitempty"` - Settings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,2,opt,name=settings" json:"settings,omitempty"` + Domain []string `protobuf:"bytes,1,rep,name=domain" json:"domain,omitempty"` + Settings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,opt,name=settings" json:"settings,omitempty"` } func (m *Server) Reset() { *m = Server{} } @@ -171,7 +171,7 @@ func (m *Server) String() string { return proto.CompactTextString(m) func (*Server) ProtoMessage() {} func (*Server) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } -func (m *Server) GetSettings() *v2ray_core_common_loader.TypedSettings { +func (m *Server) GetSettings() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Settings } @@ -204,25 +204,25 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/app/web/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 305 bytes of a gzipped FileDescriptorProto + // 312 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x4b, 0xc3, 0x30, - 0x14, 0xc6, 0xad, 0xdb, 0x8a, 0x7d, 0xbd, 0x05, 0x19, 0x65, 0x07, 0x19, 0x53, 0xd8, 0xf0, 0x90, - 0x42, 0xbd, 0x89, 0xa7, 0x6d, 0x8a, 0x37, 0xa5, 0xf3, 0xe4, 0x41, 0x68, 0xb3, 0xe7, 0x0c, 0xac, - 0x4d, 0x78, 0x0b, 0x2b, 0xfd, 0x8f, 0xfc, 0x33, 0xa5, 0x49, 0x74, 0xa2, 0xbb, 0xe5, 0xe5, 0xfd, - 0xbe, 0xf7, 0xbe, 0x7c, 0x81, 0xcb, 0x7d, 0x46, 0x45, 0xcb, 0x85, 0xaa, 0x52, 0xa1, 0x08, 0xd3, - 0x42, 0xeb, 0xb4, 0xc1, 0x32, 0x15, 0xaa, 0x7e, 0x97, 0x1b, 0xae, 0x49, 0x19, 0xc5, 0xd8, 0x37, - 0x44, 0xc8, 0x0b, 0xad, 0x79, 0x83, 0xe5, 0x68, 0xfa, 0x47, 0x28, 0x54, 0x55, 0xa9, 0x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 0xa3, 0xfd, 0xbe, 0xb5, + 0xbd, 0x62, 0x0c, 0x86, 0x5a, 0x98, 0x8f, 0x68, 0xd0, 0xb5, 0x32, 0x7b, 0x4e, 0x43, 0x08, 0x3a, + 0xef, 0x03, 0x2d, 0x24, 0xcd, 0x96, 0xe0, 0xf7, 0x29, 0xc7, 0xe0, 0x2f, 0x55, 0x29, 0x64, 0x65, + 0x63, 0x06, 0x59, 0x5f, 0xb1, 0x14, 0x0e, 0x6a, 0x34, 0x46, 0x56, 0xab, 0xda, 0x6e, 0x08, 0x93, + 0xd3, 0xdf, 0x0f, 0x70, 0x34, 0xb8, 0xa3, 0xc1, 0x9f, 0x3b, 0x1a, 0xf7, 0x0e, 0x46, 0xf6, 0xe3, + 0x9b, 0x5d, 0x81, 0x7f, 0x6d, 0x31, 0xb3, 0x04, 0xfc, 0xda, 0xee, 0xeb, 0x61, 0x4c, 0x76, 0xc1, + 0x70, 0x89, 0xb2, 0x5e, 0x99, 0x9e, 0xc1, 0xb8, 0x50, 0xe5, 0x0e, 0x61, 0x1a, 0xba, 0xa9, 0x8f, + 0x1d, 0xf5, 0x97, 0x41, 0x83, 0x79, 0xee, 0xdb, 0x1f, 0xb8, 0xf8, 0x0a, 0x00, 0x00, 0xff, 0xff, + 0x21, 0xbf, 0x92, 0xe3, 0xee, 0x01, 0x00, 0x00, } diff --git a/app/web/config.proto b/app/web/config.proto index 0cc9209b..e905a34a 100644 --- a/app/web/config.proto +++ b/app/web/config.proto @@ -5,7 +5,7 @@ option go_package = "web"; option java_package = "com.v2ray.core.app.web"; option java_outer_classname = "ConfigProto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; message FileServer { message Entry { @@ -21,7 +21,7 @@ message FileServer { message Server { repeated string domain = 1; - v2ray.core.common.loader.TypedSettings settings = 2; + v2ray.core.common.serial.TypedMessage settings = 2; } message Config { diff --git a/common/loader/type.go b/common/loader/type.go deleted file mode 100644 index 8862f909..00000000 --- a/common/loader/type.go +++ /dev/null @@ -1,50 +0,0 @@ -package loader - -import ( - "reflect" - - "github.com/golang/protobuf/proto" - "v2ray.com/core/common/errors" -) - -func NewTypedSettings(message proto.Message) *TypedSettings { - if message == nil { - return nil - } - settings, _ := proto.Marshal(message) - return &TypedSettings{ - Type: GetType(message), - Settings: settings, - } -} - -func GetType(message proto.Message) string { - return proto.MessageName(message) -} - -func GetInstance(messageType string) (interface{}, error) { - mType := proto.MessageType(messageType).Elem() - if mType == nil { - return nil, errors.New("Unknown type: " + messageType) - } - return reflect.New(mType).Interface(), nil -} - -func (v *TypedSettings) Load(message proto.Message) error { - targetType := GetType(message) - if targetType != v.Type { - return errors.New("Have type " + v.Type + ", but retrieved for " + targetType) - } - return proto.Unmarshal(v.Settings, message) -} - -func (v *TypedSettings) GetInstance() (interface{}, error) { - instance, err := GetInstance(v.Type) - if err != nil { - return nil, err - } - if err := proto.Unmarshal(v.Settings, instance.(proto.Message)); err != nil { - return nil, err - } - return instance, nil -} diff --git a/common/loader/type.pb.go b/common/loader/type.pb.go deleted file mode 100644 index 3ed3bf02..00000000 --- a/common/loader/type.pb.go +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by protoc-gen-go. -// source: v2ray.com/core/common/loader/type.proto -// DO NOT EDIT! - -/* -Package loader is a generated protocol buffer package. - -It is generated from these files: - v2ray.com/core/common/loader/type.proto - -It has these top-level messages: - TypedSettings -*/ -package loader - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// Serialized proto message along with its type name. -type TypedSettings struct { - // The name of the message type, retrieved from protobuf API. - Type string `protobuf:"bytes,1,opt,name=type" json:"type,omitempty"` - // Serialized proto message. - Settings []byte `protobuf:"bytes,2,opt,name=settings,proto3" json:"settings,omitempty"` -} - -func (m *TypedSettings) Reset() { *m = TypedSettings{} } -func (m *TypedSettings) String() string { return proto.CompactTextString(m) } -func (*TypedSettings) ProtoMessage() {} -func (*TypedSettings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func init() { - proto.RegisterType((*TypedSettings)(nil), "v2ray.core.common.loader.TypedSettings") -} - -func init() { proto.RegisterFile("v2ray.com/core/common/loader/type.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 151 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x2f, 0x33, 0x2a, 0x4a, - 0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, - 0xcf, 0xd3, 0xcf, 0xc9, 0x4f, 0x4c, 0x49, 0x2d, 0xd2, 0x2f, 0xa9, 0x2c, 0x48, 0xd5, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, 0x29, 0x2c, 0x4a, 0xd5, 0x83, 0x28, 0xd2, 0x83, 0x28, 0x52, - 0xb2, 0xe7, 0xe2, 0x0d, 0xa9, 0x2c, 0x48, 0x4d, 0x09, 0x4e, 0x2d, 0x29, 0xc9, 0xcc, 0x4b, 0x2f, - 0x16, 0x12, 0xe2, 0x62, 0x01, 0x69, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, - 0xa4, 0xb8, 0x38, 0x8a, 0xa1, 0xf2, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x70, 0xbe, 0x93, - 0x21, 0x97, 0x4c, 0x72, 0x7e, 0xae, 0x1e, 0x2e, 0x0b, 0x9c, 0x38, 0x41, 0xc6, 0x07, 0x80, 0x5c, - 0x11, 0xc5, 0x06, 0x11, 0x4a, 0x62, 0x03, 0x3b, 0xca, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x24, - 0xa2, 0x4d, 0x76, 0xbf, 0x00, 0x00, 0x00, -} diff --git a/common/loader/type.proto b/common/loader/type.proto deleted file mode 100644 index d311f01b..00000000 --- a/common/loader/type.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package v2ray.core.common.loader; -option go_package = "loader"; -option java_package = "com.v2ray.core.common.loader"; -option java_outer_classname = "TypeProto"; - -// Serialized proto message along with its type name. -message TypedSettings { - // The name of the message type, retrieved from protobuf API. - string type = 1; - // Serialized proto message. - bytes settings = 2; -} \ No newline at end of file diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index 6d5ea180..cbe57d32 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -7,7 +7,7 @@ package protocol import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -18,7 +18,7 @@ type User struct { Level uint32 `protobuf:"varint,1,opt,name=level" json:"level,omitempty"` Email string `protobuf:"bytes,2,opt,name=email" json:"email,omitempty"` // Protocol specific account information. - Account *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,3,opt,name=account" json:"account,omitempty"` + Account *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,3,opt,name=account" json:"account,omitempty"` } func (m *User) Reset() { *m = User{} } @@ -26,7 +26,7 @@ func (m *User) String() string { return proto.CompactTextString(m) } func (*User) ProtoMessage() {} func (*User) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } -func (m *User) GetAccount() *v2ray_core_common_loader.TypedSettings { +func (m *User) GetAccount() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Account } @@ -40,18 +40,18 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/common/protocol/user.proto", fileDescriptor2) } var fileDescriptor2 = []byte{ - // 200 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x8f, 0x3f, 0xef, 0x82, 0x30, - 0x10, 0x86, 0xd3, 0xdf, 0x5f, 0xa9, 0x71, 0x21, 0x0e, 0x84, 0xc1, 0x10, 0x17, 0x70, 0x69, 0x13, - 0x8c, 0x1f, 0x40, 0x3e, 0x81, 0x41, 0x5d, 0xdc, 0x6a, 0xb9, 0x18, 0x92, 0x96, 0x23, 0xa5, 0x90, - 0xf0, 0xed, 0x0d, 0x34, 0x9d, 0xd4, 0xad, 0xcf, 0x9b, 0xa7, 0x77, 0xef, 0xd1, 0xdd, 0x90, 0x1b, - 0x31, 0x32, 0x89, 0x9a, 0x4b, 0x34, 0xc0, 0x25, 0x6a, 0x8d, 0x0d, 0x6f, 0x0d, 0x5a, 0x94, 0xa8, - 0x78, 0xdf, 0x81, 0x61, 0x33, 0x85, 0xb1, 0x57, 0x0d, 0x30, 0xa7, 0x31, 0xaf, 0xc5, 0xe9, 0xfb, - 0x31, 0x0a, 0x45, 0x05, 0x86, 0xdb, 0xb1, 0x05, 0xe7, 0x6e, 0x7b, 0xfa, 0x73, 0xed, 0xc0, 0x84, - 0x6b, 0xfa, 0xab, 0x60, 0x00, 0x15, 0x91, 0x84, 0x64, 0xab, 0xd2, 0xc1, 0x94, 0x82, 0x16, 0xb5, - 0x8a, 0xbe, 0x12, 0x92, 0x05, 0xa5, 0x83, 0xf0, 0x48, 0xff, 0x85, 0x94, 0xd8, 0x37, 0x36, 0xfa, - 0x4e, 0x48, 0xb6, 0xcc, 0x53, 0xf6, 0x5a, 0xc5, 0xad, 0x62, 0x97, 0xb1, 0x85, 0xea, 0x0c, 0xd6, - 0xd6, 0xcd, 0xa3, 0x2b, 0xfd, 0xbf, 0xe2, 0x40, 0x37, 0x12, 0x35, 0xfb, 0x7c, 0x41, 0x11, 0x4c, - 0xb5, 0x4e, 0x13, 0xdd, 0x16, 0x3e, 0xbc, 0xff, 0xcd, 0xaf, 0xfd, 0x33, 0x00, 0x00, 0xff, 0xff, - 0x68, 0x83, 0xed, 0x6b, 0x26, 0x01, 0x00, 0x00, + // 204 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x2c, 0x33, 0x2a, 0x4a, + 0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, + 0xcf, 0xd3, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x2d, 0x4e, 0x2d, 0xd2, + 0x03, 0xf3, 0x84, 0xa4, 0x60, 0x4a, 0x8b, 0x52, 0xf5, 0x20, 0xca, 0xf4, 0x60, 0xca, 0xa4, 0x0c, + 0xb0, 0x1b, 0x53, 0x9c, 0x5a, 0x94, 0x99, 0x98, 0xa3, 0x5f, 0x52, 0x59, 0x90, 0x9a, 0x12, 0x9f, + 0x9b, 0x5a, 0x5c, 0x9c, 0x98, 0x9e, 0x0a, 0xd1, 0xa4, 0x54, 0xc2, 0xc5, 0x12, 0x5a, 0x9c, 0x5a, + 0x24, 0x24, 0xc2, 0xc5, 0x9a, 0x93, 0x5a, 0x96, 0x9a, 0x23, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x1b, + 0x04, 0xe1, 0x80, 0x44, 0x53, 0x73, 0x13, 0x33, 0x73, 0x24, 0x98, 0x14, 0x18, 0x35, 0x38, 0x83, + 0x20, 0x1c, 0x21, 0x07, 0x2e, 0xf6, 0xc4, 0xe4, 0xe4, 0xfc, 0xd2, 0xbc, 0x12, 0x09, 0x66, 0x05, + 0x46, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x4c, 0x37, 0x41, 0xec, 0xd4, 0x0b, 0x01, 0xd9, 0xe9, 0x0b, + 0xb1, 0x32, 0x08, 0xa6, 0xcd, 0xc9, 0x94, 0x4b, 0x2e, 0x39, 0x3f, 0x57, 0x0f, 0xb7, 0x4f, 0x9c, + 0x38, 0x41, 0xae, 0x0a, 0x00, 0xf1, 0xa2, 0x38, 0x60, 0x82, 0x49, 0x6c, 0x60, 0x96, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x2e, 0x02, 0xab, 0x48, 0x2e, 0x01, 0x00, 0x00, } diff --git a/common/protocol/user.proto b/common/protocol/user.proto index 15f3e120..57ec5c0e 100644 --- a/common/protocol/user.proto +++ b/common/protocol/user.proto @@ -5,12 +5,12 @@ option go_package = "protocol"; option java_package = "com.v2ray.core.common.protocol"; option java_outer_classname = "UserProto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; message User { uint32 level = 1; string email = 2; // Protocol specific account information. - v2ray.core.common.loader.TypedSettings account = 3; + v2ray.core.common.serial.TypedMessage account = 3; } \ No newline at end of file diff --git a/common/serial/typed_message.go b/common/serial/typed_message.go new file mode 100644 index 00000000..b19e8b60 --- /dev/null +++ b/common/serial/typed_message.go @@ -0,0 +1,42 @@ +package serial + +import ( + "errors" + "reflect" + + "github.com/golang/protobuf/proto" +) + +func ToTypedMessage(message proto.Message) *TypedMessage { + if message == nil { + return nil + } + settings, _ := proto.Marshal(message) + return &TypedMessage{ + Type: GetMessageType(message), + Value: settings, + } +} + +func GetMessageType(message proto.Message) string { + return proto.MessageName(message) +} + +func GetInstance(messageType string) (interface{}, error) { + mType := proto.MessageType(messageType).Elem() + if mType == nil { + return nil, errors.New("Unknown type: " + messageType) + } + return reflect.New(mType).Interface(), nil +} + +func (v *TypedMessage) GetInstance() (interface{}, error) { + instance, err := GetInstance(v.Type) + if err != nil { + return nil, err + } + if err := proto.Unmarshal(v.Value, instance.(proto.Message)); err != nil { + return nil, err + } + return instance, nil +} diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go new file mode 100644 index 00000000..5320c1c3 --- /dev/null +++ b/common/serial/typed_message.pb.go @@ -0,0 +1,62 @@ +// Code generated by protoc-gen-go. +// source: v2ray.com/core/common/serial/typed_message.proto +// DO NOT EDIT! + +/* +Package serial is a generated protocol buffer package. + +It is generated from these files: + v2ray.com/core/common/serial/typed_message.proto + +It has these top-level messages: + TypedMessage +*/ +package serial + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +// Serialized proto message along with its type name. +type TypedMessage struct { + // The name of the message type, retrieved from protobuf API. + Type string `protobuf:"bytes,1,opt,name=type" json:"type,omitempty"` + // Serialized proto message. + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *TypedMessage) Reset() { *m = TypedMessage{} } +func (m *TypedMessage) String() string { return proto.CompactTextString(m) } +func (*TypedMessage) ProtoMessage() {} +func (*TypedMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func init() { + proto.RegisterType((*TypedMessage)(nil), "v2ray.core.common.serial.TypedMessage") +} + +func init() { proto.RegisterFile("v2ray.com/core/common/serial/typed_message.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 156 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x32, 0x28, 0x33, 0x2a, 0x4a, + 0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, + 0xcf, 0xd3, 0x2f, 0x4e, 0x2d, 0xca, 0x4c, 0xcc, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x4d, 0x89, 0xcf, + 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, 0xe9, + 0x28, 0x4a, 0xd5, 0x83, 0xa8, 0xd6, 0x83, 0xa8, 0x56, 0xb2, 0xe0, 0xe2, 0x09, 0x01, 0x69, 0xf0, + 0x85, 0xa8, 0x17, 0x12, 0xe2, 0x62, 0x01, 0x19, 0x20, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, + 0x66, 0x0b, 0x89, 0x70, 0xb1, 0x96, 0x25, 0xe6, 0x94, 0xa6, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0xf0, + 0x04, 0x41, 0x38, 0x4e, 0x96, 0x5c, 0x32, 0xc9, 0xf9, 0xb9, 0x7a, 0xb8, 0x4c, 0x76, 0x12, 0x44, + 0x36, 0x37, 0x00, 0xe4, 0x8c, 0x28, 0x36, 0x88, 0x54, 0x12, 0x1b, 0xd8, 0x55, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xb5, 0x17, 0x99, 0x4c, 0xc9, 0x00, 0x00, 0x00, +} diff --git a/common/serial/typed_message.proto b/common/serial/typed_message.proto new file mode 100644 index 00000000..4cb3f0ef --- /dev/null +++ b/common/serial/typed_message.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package v2ray.core.common.serial; +option go_package = "serial"; +option java_package = "com.v2ray.core.common.serial"; +option java_outer_classname = "TypedMessageProto"; + +// Serialized proto message along with its type name. +message TypedMessage { + // The name of the message type, retrieved from protobuf API. + string type = 1; + // Serialized proto message. + bytes value = 2; +} diff --git a/config.pb.go b/config.pb.go index 2f1faabb..82402574 100644 --- a/config.pb.go +++ b/config.pb.go @@ -21,7 +21,7 @@ package core import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" import v2ray_core_common_net "v2ray.com/core/common/net" import v2ray_core_common_net1 "v2ray.com/core/common/net" import v2ray_core_common_log "v2ray.com/core/common/log" @@ -138,7 +138,7 @@ func (m *AllocationStrategy) GetRefresh() *AllocationStrategyRefresh { // Config for an inbound connection handler. type InboundConnectionConfig struct { // Protocol specific settings. Must be one of the supported protocols. - Settings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"` + Settings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"` // Range of port number to run on. Both inclusive. PortRange *v2ray_core_common_net.PortRange `protobuf:"bytes,2,opt,name=port_range,json=portRange" json:"port_range,omitempty"` // IP address to listen on. 0.0.0.0 if unset. @@ -155,7 +155,7 @@ func (m *InboundConnectionConfig) String() string { return proto.Comp func (*InboundConnectionConfig) ProtoMessage() {} func (*InboundConnectionConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } -func (m *InboundConnectionConfig) GetSettings() *v2ray_core_common_loader.TypedSettings { +func (m *InboundConnectionConfig) GetSettings() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Settings } @@ -192,7 +192,7 @@ func (m *InboundConnectionConfig) GetStreamSettings() *v2ray_core_transport_inte // Config for an outbound connection handler. type OutboundConnectionConfig struct { - Settings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"` + Settings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"` // IP address to send data through. 0.0.0.0 if unset. SendThrough *v2ray_core_common_net1.IPOrDomain `protobuf:"bytes,2,opt,name=send_through,json=sendThrough" json:"send_through,omitempty"` StreamSettings *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,3,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"` @@ -205,7 +205,7 @@ func (m *OutboundConnectionConfig) String() string { return proto.Com func (*OutboundConnectionConfig) ProtoMessage() {} func (*OutboundConnectionConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } -func (m *OutboundConnectionConfig) GetSettings() *v2ray_core_common_loader.TypedSettings { +func (m *OutboundConnectionConfig) GetSettings() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Settings } @@ -240,8 +240,8 @@ type Config struct { Outbound []*OutboundConnectionConfig `protobuf:"bytes,2,rep,name=outbound" json:"outbound,omitempty"` Log *v2ray_core_common_log.Config `protobuf:"bytes,3,opt,name=log" json:"log,omitempty"` // App configuration. Must be one in the app directory. - App []*v2ray_core_common_loader.TypedSettings `protobuf:"bytes,4,rep,name=app" json:"app,omitempty"` - Transport *v2ray_core_transport.Config `protobuf:"bytes,5,opt,name=transport" json:"transport,omitempty"` + App []*v2ray_core_common_serial.TypedMessage `protobuf:"bytes,4,rep,name=app" json:"app,omitempty"` + Transport *v2ray_core_transport.Config `protobuf:"bytes,5,opt,name=transport" json:"transport,omitempty"` } func (m *Config) Reset() { *m = Config{} } @@ -270,7 +270,7 @@ func (m *Config) GetLog() *v2ray_core_common_log.Config { return nil } -func (m *Config) GetApp() []*v2ray_core_common_loader.TypedSettings { +func (m *Config) GetApp() []*v2ray_core_common_serial.TypedMessage { if m != nil { return m.App } @@ -298,50 +298,51 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 719 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x95, 0xdd, 0x6e, 0xd3, 0x30, - 0x1c, 0xc5, 0x97, 0xb6, 0xeb, 0xda, 0x7f, 0xb7, 0x52, 0x19, 0x04, 0x61, 0x30, 0x54, 0xba, 0xaf, - 0x32, 0x50, 0x2a, 0x8a, 0x10, 0x1f, 0x12, 0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x6c, 0xbd, 0x74, 0xf9, 0xea, - 0x98, 0x73, 0xb8, 0xf0, 0x88, 0x41, 0x1f, 0xa0, 0xc0, 0x4d, 0x57, 0x76, 0x46, 0xf3, 0x1b, 0x93, - 0xfc, 0xbc, 0x1e, 0x71, 0x4a, 0xa1, 0x06, 0x64, 0x03, 0xee, 0x99, 0xe8, 0xd6, 0x66, 0x96, 0xe9, - 0x39, 0x86, 0x52, 0x4a, 0xf4, 0x06, 0xb2, 0x24, 0x8a, 0xec, 0x9c, 0x9e, 0xed, 0xc6, 0xed, 0x2b, - 0x06, 0xbd, 0x85, 0x62, 0x1a, 0x9d, 0xc9, 0xf5, 0xe1, 0xec, 0x5c, 0xcd, 0x84, 0x63, 0xf9, 0xce, - 0x16, 0x2c, 0x27, 0x2f, 0x3f, 0x71, 0x11, 0x12, 0xa9, 0x6e, 0xa2, 0x8e, 0xba, 0xfa, 0x8f, 0x07, - 0x27, 0x95, 0x05, 0x54, 0x80, 0xdc, 0xe7, 0x6e, 0xfb, 0x6b, 0xc5, 0xda, 0x5f, 0x87, 0xb2, 0xcb, - 0xc3, 0x09, 0xd7, 0xfd, 0x52, 0xc2, 0x69, 0xf5, 0xf7, 0x9c, 0x7a, 0x75, 0x9c, 0xd7, 0xff, 0x1a, - 0x2f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x6f, 0x70, 0x9e, 0x57, 0x07, 0x00, 0x00, + // 733 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x95, 0xed, 0x6e, 0xd3, 0x3a, + 0x1c, 0xc6, 0x97, 0xb6, 0xeb, 0xda, 0x7f, 0xb7, 0x9e, 0xca, 0xe7, 0xe8, 0x9c, 0x9c, 0xc1, 0x50, + 0xe9, 0x5e, 0x28, 0x03, 0xa5, 0x50, 0x84, 0x98, 0x90, 0x60, 0xec, 0x05, 0xa4, 0x81, 0xa0, 0x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, 0x92, 0x53, 0x4e, 0xc4, 0xd9, 0x1c, 0xe4, 0x6b, 0x0e, + 0xd0, 0x34, 0x83, 0x5e, 0x40, 0x41, 0xa5, 0xac, 0xb5, 0xd5, 0xf6, 0xba, 0x33, 0xee, 0xc6, 0x99, + 0x56, 0x3b, 0xc7, 0xc3, 0x84, 0xb8, 0x1a, 0x40, 0x1f, 0xa0, 0xe2, 0x8f, 0xf7, 0x69, 0xe7, 0xea, + 0x56, 0xb3, 0xd2, 0x7e, 0x78, 0x3d, 0x3f, 0xf1, 0x62, 0xee, 0x24, 0x8d, 0x76, 0x61, 0x89, 0x9b, + 0xdd, 0xdb, 0x79, 0x6d, 0xb4, 0x79, 0xbd, 0x51, 0xfa, 0xaa, 0xee, 0x88, 0x6a, 0x3c, 0x86, 0x82, + 0xda, 0x1b, 0x02, 0x28, 0xee, 0x45, 0x17, 0x78, 0x28, 0x6a, 0x0b, 0xea, 0xda, 0xc5, 0xb4, 0xcf, + 0xe2, 0x9a, 0x85, 0x96, 0xa1, 0xf4, 0xf6, 0x52, 0xf5, 0x84, 0xa3, 0x5a, 0xae, 0xf1, 0x3d, 0x0f, + 0xff, 0x1d, 0xd1, 0x13, 0x36, 0xa0, 0xfd, 0x03, 0x46, 0x29, 0xf1, 0x95, 0xf7, 0x81, 0xee, 0x05, + 0xed, 0x43, 0x49, 0x10, 0x29, 0x43, 0x1a, 0x08, 0x1d, 0x4a, 0xa5, 0xbd, 0x35, 0xb9, 0x17, 0x33, + 0x1f, 0x8e, 0x19, 0x50, 0x9d, 0x47, 0xff, 0xa3, 0x99, 0x4f, 0x37, 0xe3, 0xd0, 0x2e, 0x80, 0xaa, + 0xda, 0xe3, 0x98, 0x06, 0x24, 0x8d, 0xa6, 0x3e, 0xc3, 0x85, 0x12, 0xe9, 0x74, 0x19, 0x97, 0xae, + 0xd2, 0xb9, 0xe5, 0x64, 0x74, 0x89, 0x5e, 0x43, 0x39, 0x0a, 0x85, 0x24, 0xd4, 0x63, 0x34,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0xfd, 0xd8, 0x56, 0x3d, 0xdf, 0xac, 0x5c, 0x3d, 0x38, 0xe6, 0x7c, 0x5a, 0xee, + 0x88, 0x41, 0x6f, 0xa0, 0xc4, 0xd2, 0xaa, 0xec, 0x9c, 0xe6, 0x37, 0x26, 0xf9, 0x79, 0x35, 0xba, + 0x19, 0x85, 0x5a, 0x90, 0x8f, 0x58, 0x90, 0x46, 0xb7, 0x36, 0xa3, 0x83, 0x88, 0x05, 0x4e, 0x4a, + 0x29, 0x25, 0xda, 0x81, 0x3c, 0x4e, 0x12, 0xbb, 0xa0, 0x57, 0xbb, 0x6d, 0xf9, 0x0a, 0x41, 0x2f, + 0xa1, 0x9c, 0x25, 0x97, 0xc6, 0x7a, 0x77, 0x76, 0xac, 0xe9, 0x7a, 0x63, 0xf9, 0xf6, 0x16, 0x2c, + 0x9b, 0x9b, 0xef, 0x18, 0x8f, 0xb1, 0x54, 0xc7, 0x50, 0x57, 0x9d, 0xfb, 0x27, 0x83, 0xd3, 0xda, + 0x02, 0x2a, 0x41, 0xe1, 0x7d, 0xaf, 0xf3, 0xa9, 0x66, 0xed, 0xaf, 0x43, 0xd5, 0x67, 0xf1, 0x84, + 0xeb, 0x7e, 0xc5, 0x70, 0x5a, 0xfd, 0xa5, 0xa0, 0x6e, 0x9d, 0x14, 0xf5, 0x5f, 0xc6, 0xb3, 0x9f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xbe, 0x70, 0x63, 0x5d, 0x07, 0x00, 0x00, } diff --git a/config.proto b/config.proto index 36dde67e..00d38fb7 100644 --- a/config.proto +++ b/config.proto @@ -5,7 +5,7 @@ option go_package = "core"; option java_package = "com.v2ray.core"; option java_outer_classname = "ConfigProto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; import "v2ray.com/core/common/net/port.proto"; import "v2ray.com/core/common/net/address.proto"; import "v2ray.com/core/common/log/config.proto"; @@ -52,7 +52,7 @@ message AllocationStrategy { // Config for an inbound connection handler. message InboundConnectionConfig { // Protocol specific settings. Must be one of the supported protocols. - v2ray.core.common.loader.TypedSettings settings = 1; + v2ray.core.common.serial.TypedMessage settings = 1; // Range of port number to run on. Both inclusive. v2ray.core.common.net.PortRange port_range = 2; @@ -72,7 +72,7 @@ message InboundConnectionConfig { // Config for an outbound connection handler. message OutboundConnectionConfig { - v2ray.core.common.loader.TypedSettings settings = 1; + v2ray.core.common.serial.TypedMessage settings = 1; // IP address to send data through. 0.0.0.0 if unset. v2ray.core.common.net.IPOrDomain send_through = 2; @@ -90,6 +90,6 @@ message Config { v2ray.core.common.log.Config log = 3; // App configuration. Must be one in the app directory. - repeated v2ray.core.common.loader.TypedSettings app = 4; + repeated v2ray.core.common.serial.TypedMessage app = 4; v2ray.core.transport.Config transport = 5; } \ No newline at end of file diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index cde2dfbf..f93eb0b8 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -18,7 +18,7 @@ package blackhole import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -48,7 +48,7 @@ func (*HTTPResponse) ProtoMessage() {} func (*HTTPResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } type Config struct { - Response *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,1,opt,name=response" json:"response,omitempty"` + Response *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,1,opt,name=response" json:"response,omitempty"` } func (m *Config) Reset() { *m = Config{} } @@ -56,7 +56,7 @@ func (m *Config) String() string { return proto.CompactTextString(m) func (*Config) ProtoMessage() {} func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } -func (m *Config) GetResponse() *v2ray_core_common_loader.TypedSettings { +func (m *Config) GetResponse() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Response } @@ -72,18 +72,18 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/proxy/blackhole/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 203 bytes of a gzipped FileDescriptorProto + // 205 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x2e, 0x33, 0x2a, 0x4a, 0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x28, 0xca, 0xaf, 0xa8, 0xd4, 0x4f, 0xca, 0x49, 0x4c, 0xce, 0xce, 0xc8, 0xcf, 0x49, 0xd5, 0x4f, 0xce, 0xcf, 0x4b, 0xcb, 0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x82, 0x29, 0x2e, 0x4a, 0xd5, 0x03, 0x2b, - 0xd4, 0x83, 0x2b, 0x94, 0x52, 0x47, 0x33, 0x28, 0x39, 0x3f, 0x37, 0x37, 0x3f, 0x4f, 0x3f, 0x27, - 0x3f, 0x31, 0x25, 0xb5, 0x48, 0xbf, 0xa4, 0xb2, 0x20, 0x15, 0x62, 0x88, 0x12, 0x1f, 0x17, 0x8f, - 0x5f, 0x7e, 0x5e, 0x6a, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, 0x88, 0xef, 0x11, 0x12, - 0x12, 0x00, 0xe7, 0xfb, 0x72, 0xb1, 0x39, 0x83, 0x2d, 0x15, 0x72, 0xe6, 0xe2, 0x28, 0x82, 0x8a, - 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0xa9, 0xeb, 0x21, 0xb9, 0x00, 0x62, 0x83, 0x1e, 0xc4, - 0x06, 0xbd, 0x90, 0xca, 0x82, 0xd4, 0x94, 0xe0, 0xd4, 0x92, 0x92, 0xcc, 0xbc, 0xf4, 0xe2, 0x20, - 0xb8, 0x46, 0x27, 0x0b, 0x2e, 0xb9, 0xe4, 0xfc, 0x5c, 0x3d, 0xdc, 0x2e, 0x77, 0xe2, 0x86, 0x58, - 0x17, 0x00, 0x72, 0x5d, 0x14, 0x27, 0x5c, 0x3c, 0x89, 0x0d, 0xec, 0x5e, 0x63, 0x40, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x27, 0x0a, 0x95, 0x10, 0x23, 0x01, 0x00, 0x00, + 0xd4, 0x83, 0x2b, 0x94, 0x32, 0x40, 0x33, 0x28, 0x39, 0x3f, 0x37, 0x37, 0x3f, 0x4f, 0xbf, 0x38, + 0xb5, 0x28, 0x33, 0x31, 0x47, 0xbf, 0xa4, 0xb2, 0x20, 0x35, 0x25, 0x3e, 0x37, 0xb5, 0xb8, 0x38, + 0x31, 0x3d, 0x15, 0x62, 0x9a, 0x12, 0x1f, 0x17, 0x8f, 0x5f, 0x7e, 0x5e, 0x6a, 0x50, 0x6a, 0x71, + 0x41, 0x7e, 0x5e, 0x71, 0x2a, 0x88, 0xef, 0x11, 0x12, 0x12, 0x00, 0xe7, 0xfb, 0x70, 0xb1, 0x39, + 0x83, 0x6d, 0x17, 0x72, 0xe2, 0xe2, 0x28, 0x82, 0x8a, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, + 0xa9, 0xe9, 0x21, 0x39, 0x05, 0x62, 0x95, 0x1e, 0xc4, 0x2a, 0xbd, 0x10, 0x90, 0x55, 0xbe, 0x10, + 0x9b, 0x82, 0xe0, 0xfa, 0x9c, 0x2c, 0xb8, 0xe4, 0x92, 0xf3, 0x73, 0xf5, 0x70, 0xfb, 0xc0, 0x89, + 0x1b, 0x62, 0x5b, 0x00, 0xc8, 0x71, 0x51, 0x9c, 0x70, 0xf1, 0x24, 0x36, 0xb0, 0x73, 0x8d, 0x01, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x03, 0x0e, 0x8c, 0x2b, 0x01, 0x00, 0x00, } diff --git a/proxy/blackhole/config.proto b/proxy/blackhole/config.proto index f4f5d433..e51786db 100644 --- a/proxy/blackhole/config.proto +++ b/proxy/blackhole/config.proto @@ -5,7 +5,7 @@ option go_package = "blackhole"; option java_package = "com.v2ray.core.proxy.blackhole"; option java_outer_classname = "ConfigProto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; message NoneResponse { } @@ -14,5 +14,5 @@ message HTTPResponse { } message Config { - v2ray.core.common.loader.TypedSettings response = 1; + v2ray.core.common.serial.TypedMessage response = 1; } diff --git a/proxy/blackhole/init.go b/proxy/blackhole/init.go index ef73b3ae..b165987a 100644 --- a/proxy/blackhole/init.go +++ b/proxy/blackhole/init.go @@ -1,11 +1,11 @@ package blackhole import ( - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/registry" ) func init() { // Must listed after config.pb.go - registry.MustRegisterOutboundHandlerCreator(loader.GetType(new(Config)), new(Factory)) + registry.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)) } diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 06370c39..acae024f 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -7,9 +7,9 @@ import ( "v2ray.com/core/app/dispatcher" "v2ray.com/core/common/buf" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy" "v2ray.com/core/proxy/registry" "v2ray.com/core/transport/internet" @@ -212,5 +212,5 @@ func (v *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.Inb } func init() { - registry.MustRegisterInboundHandlerCreator(loader.GetType(new(Config)), new(Factory)) + registry.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)) } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index a67503df..9b7a8fc3 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -8,10 +8,10 @@ import ( "v2ray.com/core/common/buf" "v2ray.com/core/common/dice" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/retry" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy" "v2ray.com/core/proxy/registry" "v2ray.com/core/transport/internet" @@ -142,5 +142,5 @@ func (v *FreedomFactory) Create(space app.Space, config interface{}, meta *proxy } func init() { - registry.MustRegisterOutboundHandlerCreator(loader.GetType(new(Config)), new(FreedomFactory)) + registry.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(FreedomFactory)) } diff --git a/proxy/http/server.go b/proxy/http/server.go index ad6184db..4d06ed46 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -14,9 +14,9 @@ import ( "v2ray.com/core/common/buf" "v2ray.com/core/common/bufio" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy" "v2ray.com/core/proxy/registry" "v2ray.com/core/transport/internet" @@ -288,5 +288,5 @@ func (v *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *pro } func init() { - registry.MustRegisterInboundHandlerCreator(loader.GetType(new(ServerConfig)), new(ServerFactory)) + registry.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory)) } diff --git a/proxy/shadowsocks/init.go b/proxy/shadowsocks/init.go index 17cf75d5..3942e6cb 100644 --- a/proxy/shadowsocks/init.go +++ b/proxy/shadowsocks/init.go @@ -1,12 +1,12 @@ package shadowsocks import ( - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/registry" ) func init() { // Must happen after config is initialized - registry.MustRegisterOutboundHandlerCreator(loader.GetType(new(ClientConfig)), new(ClientFactory)) - registry.MustRegisterInboundHandlerCreator(loader.GetType(new(ServerConfig)), new(ServerFactory)) + registry.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(ClientConfig)), new(ClientFactory)) + registry.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory)) } diff --git a/proxy/shadowsocks/protocol_test.go b/proxy/shadowsocks/protocol_test.go index f730ed01..cfb43670 100644 --- a/proxy/shadowsocks/protocol_test.go +++ b/proxy/shadowsocks/protocol_test.go @@ -4,7 +4,6 @@ import ( "testing" "v2ray.com/core/common/buf" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" "v2ray.com/core/common/serial" @@ -22,7 +21,7 @@ func TestUDPEncoding(t *testing.T) { Port: 1234, User: &protocol.User{ Email: "love@v2ray.com", - Account: loader.NewTypedSettings(&Account{ + Account: serial.ToTypedMessage(&Account{ Password: "shadowsocks-password", CipherType: CipherType_AES_128_CFB, Ota: Account_Disabled, @@ -53,7 +52,7 @@ func TestTCPRequest(t *testing.T) { Port: 1234, User: &protocol.User{ Email: "love@v2ray.com", - Account: loader.NewTypedSettings(&Account{ + Account: serial.ToTypedMessage(&Account{ Password: "tcp-password", CipherType: CipherType_CHACHA20, }), @@ -83,7 +82,7 @@ func TestUDPReaderWriter(t *testing.T) { assert := assert.On(t) user := &protocol.User{ - Account: loader.NewTypedSettings(&Account{ + Account: serial.ToTypedMessage(&Account{ Password: "test-password", CipherType: CipherType_CHACHA20_IEFT, }), diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 94d7f659..d78b79ab 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -11,9 +11,9 @@ import ( "v2ray.com/core/common/bufio" "v2ray.com/core/common/crypto" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy" "v2ray.com/core/proxy/registry" "v2ray.com/core/proxy/socks/protocol" @@ -334,5 +334,5 @@ func (v *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *pro } func init() { - registry.MustRegisterInboundHandlerCreator(loader.GetType(new(ServerConfig)), new(ServerFactory)) + registry.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(ServerConfig)), new(ServerFactory)) } diff --git a/proxy/vmess/encoding/encoding_test.go b/proxy/vmess/encoding/encoding_test.go index 12b87c40..3d05c312 100644 --- a/proxy/vmess/encoding/encoding_test.go +++ b/proxy/vmess/encoding/encoding_test.go @@ -4,9 +4,9 @@ import ( "testing" "v2ray.com/core/common/buf" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" + "v2ray.com/core/common/serial" "v2ray.com/core/common/uuid" "v2ray.com/core/proxy/vmess" . "v2ray.com/core/proxy/vmess/encoding" @@ -24,7 +24,7 @@ func TestRequestSerialization(t *testing.T) { Id: uuid.New().String(), AlterId: 0, } - user.Account = loader.NewTypedSettings(account) + user.Account = serial.ToTypedMessage(account) expectedRequest := &protocol.RequestHeader{ Version: 1, diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 0d57f8be..4ad6cda4 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -11,10 +11,10 @@ import ( "v2ray.com/core/common/buf" "v2ray.com/core/common/bufio" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" + "v2ray.com/core/common/serial" "v2ray.com/core/common/uuid" "v2ray.com/core/proxy" "v2ray.com/core/proxy/registry" @@ -59,7 +59,7 @@ func (v *userByEmail) Get(email string) (*protocol.User, bool) { user = &protocol.User{ Level: v.defaultLevel, Email: email, - Account: loader.NewTypedSettings(account), + Account: serial.ToTypedMessage(account), } v.cache[email] = user } @@ -272,5 +272,5 @@ func (v *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.Inb } func init() { - registry.MustRegisterInboundHandlerCreator(loader.GetType(new(Config)), new(Factory)) + registry.MustRegisterInboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)) } diff --git a/proxy/vmess/outbound/command.go b/proxy/vmess/outbound/command.go index dd890e50..70bb2d3f 100644 --- a/proxy/vmess/outbound/command.go +++ b/proxy/vmess/outbound/command.go @@ -3,9 +3,9 @@ package outbound import ( "time" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/vmess" ) @@ -18,7 +18,7 @@ func (v *VMessOutboundHandler) handleSwitchAccount(cmd *protocol.CommandSwitchAc user := &protocol.User{ Email: "", Level: cmd.Level, - Account: loader.NewTypedSettings(account), + Account: serial.ToTypedMessage(account), } dest := v2net.TCPDestination(cmd.Host, cmd.Port) until := time.Now().Add(time.Duration(cmd.ValidMin) * time.Minute) diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 9fe74535..d345ea33 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -6,11 +6,11 @@ import ( "v2ray.com/core/app" "v2ray.com/core/common/buf" "v2ray.com/core/common/bufio" - "v2ray.com/core/common/loader" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" "v2ray.com/core/common/retry" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy" "v2ray.com/core/proxy/registry" "v2ray.com/core/proxy/vmess" @@ -176,5 +176,5 @@ func (v *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.Out } func init() { - registry.MustRegisterOutboundHandlerCreator(loader.GetType(new(Config)), new(Factory)) + registry.MustRegisterOutboundHandlerCreator(serial.GetMessageType(new(Config)), new(Factory)) } diff --git a/tools/conf/blackhole.go b/tools/conf/blackhole.go index 83333002..b26fc550 100644 --- a/tools/conf/blackhole.go +++ b/tools/conf/blackhole.go @@ -3,27 +3,27 @@ package conf import ( "encoding/json" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/blackhole" ) type NoneResponse struct{} -func (*NoneResponse) Build() (*loader.TypedSettings, error) { - return loader.NewTypedSettings(new(blackhole.NoneResponse)), nil +func (*NoneResponse) Build() (*serial.TypedMessage, error) { + return serial.ToTypedMessage(new(blackhole.NoneResponse)), nil } type HttpResponse struct{} -func (*HttpResponse) Build() (*loader.TypedSettings, error) { - return loader.NewTypedSettings(new(blackhole.HTTPResponse)), nil +func (*HttpResponse) Build() (*serial.TypedMessage, error) { + return serial.ToTypedMessage(new(blackhole.HTTPResponse)), nil } type BlackholeConfig struct { Response json.RawMessage `json:"response"` } -func (v *BlackholeConfig) Build() (*loader.TypedSettings, error) { +func (v *BlackholeConfig) Build() (*serial.TypedMessage, error) { config := new(blackhole.Config) if v.Response != nil { response, _, err := configLoader.Load(v.Response) @@ -37,7 +37,7 @@ func (v *BlackholeConfig) Build() (*loader.TypedSettings, error) { config.Response = responseSettings } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } var ( diff --git a/tools/conf/builable.go b/tools/conf/builable.go index 899690c1..32b14a7b 100644 --- a/tools/conf/builable.go +++ b/tools/conf/builable.go @@ -1,9 +1,9 @@ package conf import ( - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" ) type Buildable interface { - Build() (*loader.TypedSettings, error) + Build() (*serial.TypedMessage, error) } diff --git a/tools/conf/dokodemo.go b/tools/conf/dokodemo.go index b469e097..374a7193 100644 --- a/tools/conf/dokodemo.go +++ b/tools/conf/dokodemo.go @@ -1,7 +1,7 @@ package conf import ( - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/dokodemo" ) @@ -13,7 +13,7 @@ type DokodemoConfig struct { Redirect bool `json:"followRedirect"` } -func (v *DokodemoConfig) Build() (*loader.TypedSettings, error) { +func (v *DokodemoConfig) Build() (*serial.TypedMessage, error) { config := new(dokodemo.Config) if v.Host != nil { config.Address = v.Host.Build() @@ -22,5 +22,5 @@ func (v *DokodemoConfig) Build() (*loader.TypedSettings, error) { config.NetworkList = v.NetworkList.Build() config.Timeout = v.TimeoutValue config.FollowRedirect = v.Redirect - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/tools/conf/freedom.go b/tools/conf/freedom.go index d54e6c96..bd299ed4 100644 --- a/tools/conf/freedom.go +++ b/tools/conf/freedom.go @@ -3,7 +3,7 @@ package conf import ( "strings" - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/freedom" ) @@ -12,7 +12,7 @@ type FreedomConfig struct { Timeout uint32 `json:"timeout"` } -func (v *FreedomConfig) Build() (*loader.TypedSettings, error) { +func (v *FreedomConfig) Build() (*serial.TypedMessage, error) { config := new(freedom.Config) config.DomainStrategy = freedom.Config_AS_IS domainStrategy := strings.ToLower(v.DomainStrategy) @@ -20,5 +20,5 @@ func (v *FreedomConfig) Build() (*loader.TypedSettings, error) { config.DomainStrategy = freedom.Config_USE_IP } config.Timeout = v.Timeout - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/tools/conf/http.go b/tools/conf/http.go index 944be624..f788602d 100644 --- a/tools/conf/http.go +++ b/tools/conf/http.go @@ -1,7 +1,7 @@ package conf import ( - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/http" ) @@ -9,10 +9,10 @@ type HttpServerConfig struct { Timeout uint32 `json:"timeout"` } -func (v *HttpServerConfig) Build() (*loader.TypedSettings, error) { +func (v *HttpServerConfig) Build() (*serial.TypedMessage, error) { config := &http.ServerConfig{ Timeout: v.Timeout, } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/tools/conf/shadowsocks.go b/tools/conf/shadowsocks.go index f48452aa..476f4042 100644 --- a/tools/conf/shadowsocks.go +++ b/tools/conf/shadowsocks.go @@ -3,8 +3,8 @@ package conf import ( "strings" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/protocol" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/shadowsocks" ) @@ -17,7 +17,7 @@ type ShadowsocksServerConfig struct { OTA *bool `json:"ota"` } -func (v *ShadowsocksServerConfig) Build() (*loader.TypedSettings, error) { +func (v *ShadowsocksServerConfig) Build() (*serial.TypedMessage, error) { config := new(shadowsocks.ServerConfig) config.UdpEnabled = v.UDP @@ -52,10 +52,10 @@ func (v *ShadowsocksServerConfig) Build() (*loader.TypedSettings, error) { config.User = &protocol.User{ Email: v.Email, Level: uint32(v.Level), - Account: loader.NewTypedSettings(account), + Account: serial.ToTypedMessage(account), } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type ShadowsocksServerTarget struct { @@ -71,7 +71,7 @@ type ShadowsocksClientConfig struct { Servers []*ShadowsocksServerTarget `json:"servers"` } -func (v *ShadowsocksClientConfig) Build() (*loader.TypedSettings, error) { +func (v *ShadowsocksClientConfig) Build() (*serial.TypedMessage, error) { config := new(shadowsocks.ClientConfig) if len(v.Servers) == 0 { @@ -116,7 +116,7 @@ func (v *ShadowsocksClientConfig) Build() (*loader.TypedSettings, error) { User: []*protocol.User{ { Email: server.Email, - Account: loader.NewTypedSettings(account), + Account: serial.ToTypedMessage(account), }, }, } @@ -126,5 +126,5 @@ func (v *ShadowsocksClientConfig) Build() (*loader.TypedSettings, error) { config.Server = serverSpecs - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/tools/conf/socks.go b/tools/conf/socks.go index dfd962a6..243f5f5c 100644 --- a/tools/conf/socks.go +++ b/tools/conf/socks.go @@ -3,8 +3,8 @@ package conf import ( "encoding/json" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" "v2ray.com/core/common/protocol" + "v2ray.com/core/common/serial" "v2ray.com/core/proxy/socks" ) @@ -33,7 +33,7 @@ type SocksServerConfig struct { Timeout uint32 `json:"timeout"` } -func (v *SocksServerConfig) Build() (*loader.TypedSettings, error) { +func (v *SocksServerConfig) Build() (*serial.TypedMessage, error) { config := new(socks.ServerConfig) if v.AuthMethod == AuthMethodNoAuth { config.AuthType = socks.AuthType_NO_AUTH @@ -56,7 +56,7 @@ func (v *SocksServerConfig) Build() (*loader.TypedSettings, error) { } config.Timeout = v.Timeout - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type SocksRemoteConfig struct { @@ -68,7 +68,7 @@ type SocksClientConfig struct { Servers []*SocksRemoteConfig `json:"servers"` } -func (v *SocksClientConfig) Build() (*loader.TypedSettings, error) { +func (v *SocksClientConfig) Build() (*serial.TypedMessage, error) { config := new(socks.ClientConfig) config.Server = make([]*protocol.ServerEndpoint, len(v.Servers)) for idx, serverConfig := range v.Servers { @@ -85,10 +85,10 @@ func (v *SocksClientConfig) Build() (*loader.TypedSettings, error) { if err := json.Unmarshal(rawUser, account); err != nil { return nil, errors.Base(err).Message("Socks|Client: Failed to parse socks account.") } - user.Account = loader.NewTypedSettings(account.Build()) + user.Account = serial.ToTypedMessage(account.Build()) server.User = append(server.User, user) } config.Server[idx] = server } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/tools/conf/transport_authenticators.go b/tools/conf/transport_authenticators.go index 768292d4..b8b4ff6d 100644 --- a/tools/conf/transport_authenticators.go +++ b/tools/conf/transport_authenticators.go @@ -2,7 +2,7 @@ package conf import ( "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/transport/internet/headers/http" "v2ray.com/core/transport/internet/headers/noop" "v2ray.com/core/transport/internet/headers/srtp" @@ -11,26 +11,26 @@ import ( type NoOpAuthenticator struct{} -func (NoOpAuthenticator) Build() (*loader.TypedSettings, error) { - return loader.NewTypedSettings(new(noop.Config)), nil +func (NoOpAuthenticator) Build() (*serial.TypedMessage, error) { + return serial.ToTypedMessage(new(noop.Config)), nil } type NoOpConnectionAuthenticator struct{} -func (NoOpConnectionAuthenticator) Build() (*loader.TypedSettings, error) { - return loader.NewTypedSettings(new(noop.Config)), nil +func (NoOpConnectionAuthenticator) Build() (*serial.TypedMessage, error) { + return serial.ToTypedMessage(new(noop.Config)), nil } type SRTPAuthenticator struct{} -func (SRTPAuthenticator) Build() (*loader.TypedSettings, error) { - return loader.NewTypedSettings(new(srtp.Config)), nil +func (SRTPAuthenticator) Build() (*serial.TypedMessage, error) { + return serial.ToTypedMessage(new(srtp.Config)), nil } type UTPAuthenticator struct{} -func (UTPAuthenticator) Build() (*loader.TypedSettings, error) { - return loader.NewTypedSettings(new(utp.Config)), nil +func (UTPAuthenticator) Build() (*serial.TypedMessage, error) { + return serial.ToTypedMessage(new(utp.Config)), nil } type HTTPAuthenticatorRequest struct { @@ -169,7 +169,7 @@ type HTTPAuthenticator struct { Response HTTPAuthenticatorResponse `json:"response"` } -func (v *HTTPAuthenticator) Build() (*loader.TypedSettings, error) { +func (v *HTTPAuthenticator) Build() (*serial.TypedMessage, error) { config := new(http.Config) requestConfig, err := v.Request.Build() if err != nil { @@ -183,5 +183,5 @@ func (v *HTTPAuthenticator) Build() (*loader.TypedSettings, error) { } config.Response = responseConfig - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/tools/conf/transport_internet.go b/tools/conf/transport_internet.go index 36f72b1b..043197c7 100644 --- a/tools/conf/transport_internet.go +++ b/tools/conf/transport_internet.go @@ -6,8 +6,8 @@ import ( "strings" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/transport/internet" "v2ray.com/core/transport/internet/kcp" "v2ray.com/core/transport/internet/tcp" @@ -39,7 +39,7 @@ type KCPConfig struct { HeaderConfig json.RawMessage `json:"header"` } -func (v *KCPConfig) Build() (*loader.TypedSettings, error) { +func (v *KCPConfig) Build() (*serial.TypedMessage, error) { config := new(kcp.Config) if v.Mtu != nil { @@ -93,7 +93,7 @@ func (v *KCPConfig) Build() (*loader.TypedSettings, error) { config.HeaderConfig = ts } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type TCPConfig struct { @@ -101,7 +101,7 @@ type TCPConfig struct { HeaderConfig json.RawMessage `json:"header"` } -func (v *TCPConfig) Build() (*loader.TypedSettings, error) { +func (v *TCPConfig) Build() (*serial.TypedMessage, error) { config := new(tcp.Config) if v.ConnectionReuse != nil { config.ConnectionReuse = &tcp.ConnectionReuse{ @@ -120,7 +120,7 @@ func (v *TCPConfig) Build() (*loader.TypedSettings, error) { config.HeaderSettings = ts } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type WebSocketConfig struct { @@ -128,7 +128,7 @@ type WebSocketConfig struct { Path string `json:"Path"` } -func (v *WebSocketConfig) Build() (*loader.TypedSettings, error) { +func (v *WebSocketConfig) Build() (*serial.TypedMessage, error) { config := &ws.Config{ Path: v.Path, } @@ -137,7 +137,7 @@ func (v *WebSocketConfig) Build() (*loader.TypedSettings, error) { Enable: *v.ConnectionReuse, } } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type TLSCertConfig struct { @@ -150,7 +150,7 @@ type TLSConfig struct { ServerName string `json:"serverName"` } -func (v *TLSConfig) Build() (*loader.TypedSettings, error) { +func (v *TLSConfig) Build() (*serial.TypedMessage, error) { config := new(tls.Config) config.Certificate = make([]*tls.Certificate, len(v.Certs)) for idx, certConf := range v.Certs { @@ -171,7 +171,7 @@ func (v *TLSConfig) Build() (*loader.TypedSettings, error) { if len(v.ServerName) > 0 { config.ServerName = v.ServerName } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type StreamConfig struct { diff --git a/tools/conf/v2ray.go b/tools/conf/v2ray.go index a702f934..1e9b75a8 100644 --- a/tools/conf/v2ray.go +++ b/tools/conf/v2ray.go @@ -6,8 +6,8 @@ import ( "strings" "v2ray.com/core" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" json_reader "v2ray.com/core/tools/conf/json" ) @@ -289,11 +289,11 @@ func (v *Config) Build() (*core.Config, error) { if err != nil { return nil, err } - config.App = append(config.App, loader.NewTypedSettings(routerConfig)) + config.App = append(config.App, serial.ToTypedMessage(routerConfig)) } if v.DNSConfig != nil { - config.App = append(config.App, loader.NewTypedSettings(v.DNSConfig.Build())) + config.App = append(config.App, serial.ToTypedMessage(v.DNSConfig.Build())) } if v.InboundConfig == nil { diff --git a/tools/conf/vmess.go b/tools/conf/vmess.go index 62e96dc4..8e11742b 100644 --- a/tools/conf/vmess.go +++ b/tools/conf/vmess.go @@ -5,7 +5,6 @@ import ( "strings" "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" "v2ray.com/core/common/serial" @@ -79,7 +78,7 @@ type VMessInboundConfig struct { DetourConfig *VMessDetourConfig `json:"detour"` } -func (v *VMessInboundConfig) Build() (*loader.TypedSettings, error) { +func (v *VMessInboundConfig) Build() (*serial.TypedMessage, error) { config := new(inbound.Config) if v.Defaults != nil { @@ -102,11 +101,11 @@ func (v *VMessInboundConfig) Build() (*loader.TypedSettings, error) { if err := json.Unmarshal(rawData, account); err != nil { return nil, errors.Base(err).Message("Invalid VMess user.") } - user.Account = loader.NewTypedSettings(account.Build()) + user.Account = serial.ToTypedMessage(account.Build()) config.User[idx] = user } - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } type VMessOutboundTarget struct { @@ -118,7 +117,7 @@ type VMessOutboundConfig struct { Receivers []*VMessOutboundTarget `json:"vnext"` } -func (v *VMessOutboundConfig) Build() (*loader.TypedSettings, error) { +func (v *VMessOutboundConfig) Build() (*serial.TypedMessage, error) { config := new(outbound.Config) if len(v.Receivers) == 0 { @@ -148,11 +147,11 @@ func (v *VMessOutboundConfig) Build() (*loader.TypedSettings, error) { if err := json.Unmarshal(rawUser, account); err != nil { return nil, errors.Base(err).Message("Invalid VMess user.") } - user.Account = loader.NewTypedSettings(account.Build()) + user.Account = serial.ToTypedMessage(account.Build()) spec.User = append(spec.User, user) } serverSpecs[idx] = spec } config.Receiver = serverSpecs - return loader.NewTypedSettings(config), nil + return serial.ToTypedMessage(config), nil } diff --git a/transport/internet/config.go b/transport/internet/config.go index e97b9c10..e013d414 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -2,7 +2,7 @@ package internet import ( "v2ray.com/core/common/errors" - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" ) @@ -56,7 +56,7 @@ func (v *StreamConfig) GetEffectiveSecuritySettings() (interface{}, error) { return settings.GetInstance() } } - return loader.GetInstance(v.SecurityType) + return serial.GetInstance(v.SecurityType) } func (v *StreamConfig) HasSecuritySettings() bool { diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index b314042c..359f9536 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -19,7 +19,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import v2ray_core_common_net "v2ray.com/core/common/net" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -36,7 +36,7 @@ type NetworkSettings struct { // Type of network that this settings supports. Network v2ray_core_common_net.Network `protobuf:"varint,1,opt,name=network,enum=v2ray.core.common.net.Network" json:"network,omitempty"` // Specific settings. - Settings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,2,opt,name=settings" json:"settings,omitempty"` + Settings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,opt,name=settings" json:"settings,omitempty"` } func (m *NetworkSettings) Reset() { *m = NetworkSettings{} } @@ -44,7 +44,7 @@ func (m *NetworkSettings) String() string { return proto.CompactTextS func (*NetworkSettings) ProtoMessage() {} func (*NetworkSettings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (m *NetworkSettings) GetSettings() *v2ray_core_common_loader.TypedSettings { +func (m *NetworkSettings) GetSettings() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Settings } @@ -56,8 +56,8 @@ type StreamConfig struct { Network v2ray_core_common_net.Network `protobuf:"varint,1,opt,name=network,enum=v2ray.core.common.net.Network" json:"network,omitempty"` NetworkSettings []*NetworkSettings `protobuf:"bytes,2,rep,name=network_settings,json=networkSettings" json:"network_settings,omitempty"` // Type of security. Must be a message name of the settings proto. - SecurityType string `protobuf:"bytes,3,opt,name=security_type,json=securityType" json:"security_type,omitempty"` - SecuritySettings []*v2ray_core_common_loader.TypedSettings `protobuf:"bytes,4,rep,name=security_settings,json=securitySettings" json:"security_settings,omitempty"` + SecurityType string `protobuf:"bytes,3,opt,name=security_type,json=securityType" json:"security_type,omitempty"` + SecuritySettings []*v2ray_core_common_serial.TypedMessage `protobuf:"bytes,4,rep,name=security_settings,json=securitySettings" json:"security_settings,omitempty"` } func (m *StreamConfig) Reset() { *m = StreamConfig{} } @@ -72,7 +72,7 @@ func (m *StreamConfig) GetNetworkSettings() []*NetworkSettings { return nil } -func (m *StreamConfig) GetSecuritySettings() []*v2ray_core_common_loader.TypedSettings { +func (m *StreamConfig) GetSecuritySettings() []*v2ray_core_common_serial.TypedMessage { if m != nil { return m.SecuritySettings } @@ -97,25 +97,26 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/transport/internet/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 317 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x92, 0xcd, 0x4a, 0xfb, 0x50, - 0x10, 0xc5, 0x49, 0xfb, 0xe7, 0x6f, 0x7b, 0x5b, 0x6d, 0xcd, 0xaa, 0x08, 0x6a, 0xad, 0x8b, 0x66, - 0xe3, 0x04, 0xe2, 0xc6, 0xb5, 0xdd, 0x8b, 0xa4,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, 0xa4, - 0x61, 0x8b, 0x49, 0x38, 0x30, 0x5b, 0x90, 0xce, 0xd5, 0x7e, 0x86, 0xfa, 0x85, 0x63, 0xc9, 0x97, - 0x05, 0xcf, 0x51, 0x7b, 0xec, 0x78, 0xdd, 0xb0, 0x6f, 0x97, 0xc5, 0x75, 0xee, 0x42, 0x1d, 0x36, - 0xa2, 0xa6, 0xc0, 0xbf, 0xb2, 0xc0, 0xaf, 0xc1, 0x0c, 0x6d, 0x82, 0xdd, 0x4c, 0x4e, 0x55, 0xef, - 0x96, 0xe9, 0x3d, 0xaf, 0xf1, 0x0c, 0x55, 0x5b, 0xa2, 0x75, 0x89, 0xa6, 0x1b, 0x16, 0xe3, 0xf5, - 0x85, 0x3a, 0xd3, 0x94, 0xec, 0xbe, 0xf0, 0xbe, 0x63, 0xa7, 0x87, 0xff, 0xe5, 0x57, 0xb8, 0xfc, - 0x0a, 0x00, 0x00, 0xff, 0xff, 0xa6, 0xb6, 0x2f, 0xcf, 0xad, 0x02, 0x00, 0x00, + // 325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x92, 0xcf, 0x4a, 0xc3, 0x40, + 0x10, 0xc6, 0x49, 0x2b, 0xda, 0x6e, 0xab, 0xad, 0x39, 0x95, 0x82, 0x5a, 0x2b, 0x68, 0x2e, 0x4e, + 0x24, 0x5e, 0x3c, 0xd7, 0xb3, 0x22, 0xa9, 0x17, 0xbd, 0x94, 0x18, 0xc7, 0x10, 0x34, 0xbb, 0x65, + 0x76, 0xfc, 0x93, 0xa7, 0xf0, 0x09, 0x7c, 0x57, 0x49, 0x36, 0x1b, 0x4a, 0x28, 0x45, 0xf0, 0x36, + 0x84, 0x6f, 0xbe, 0xfc, 0xe6, 0xc7, 0x0a, 0xf8, 0x08, 0x28, 0xca, 0x21, 0x56, 0x99, 0x1f, 0x2b, + 0x42, 0x9f, 0x29, 0x92, 0x7a, 0xa9, 0x88, 0xfd, 0x54, 0x32, 0x92, 0x44, 0xf6, 0x63, 0x25, 0x5f, + 0xd2, 0x04, 0x96, 0xa4, 0x58, 0xb9, 0x07, 0x36, 0x4f, 0x08, 0x75, 0x16, 0x6c, 0x76, 0x7c, 0xd6, + 0xa8, 0x8b, 0x55, 0x96, 0x29, 0xe9, 0x17, 0x35, 0x12, 0xf9, 0x53, 0xd1, 0xab, 0xe9, 0x19, 0x5f, + 0xac, 0x0f, 0x6a, 0xa4, 0x34, 0x7a, 0xf3, 0x39, 0x5f, 0xe2, 0xf3, 0x22, 0x43, 0xad, 0xa3, 0x04, + 0xcd, 0xc6, 0xf4, 0xdb, 0x11, 0x83, 0x5b, 0xd3, 0x31, 0x47, 0xe6, 0x54, 0x26, 0xda, 0xbd, 0x12, + 0x3b, 0x55, 0xed, 0xc8, 0x99, 0x38, 0xde, 0x5e, 0x70, 0x08, 0x2b, 0x7c, 0xa6, 0x13, 0x24, 0x32, + 0x54, 0x8b, 0xa1, 0x8d, 0xbb, 0x33, 0xd1, 0xd1, 0x55, 0xcb, 0xa8, 0x35, 0x71, 0xbc, 0x5e, 0x70, + 0xba, 0x66, 0xd5, 0xe0, 0xc0, 0x7d, 0x81, 0x73, 0x63, 0x68, 0xc2, 0x7a, 0x6f, 0xfa, 0xd3, 0x12, + 0xfd, 0x39, 0x13, 0x46, 0xd9, 0x75, 0xa9, 0xe8, 0x1f, 0x38, 0x0f, 0x62, 0x58, 0x8d, 0x8b, 0x15, + 0xac, 0xb6, 0xd7, 0x0b, 0x00, 0x36, 0x1a, 0x87, 0x86, 0x92, 0x70, 0x20, 0x1b, 0x8e, 0x4e, 0xc4, + 0xae, 0xc6, 0xf8, 0x9d, 0x52, 0xce, 0x17, 0x85, 0xd7, 0x51, 0x7b, 0xe2, 0x78, 0xdd, 0xb0, 0x6f, + 0x3f, 0x16, 0xc7, 0xb9, 0x73, 0xb1, 0x5f, 0x87, 0x6a, 0x80, 0xad, 0x12, 0xe0, 0xaf, 0x5e, 0x86, + 0xb6, 0xc0, 0xfe, 0x79, 0x7a, 0x24, 0x7a, 0x77, 0xa4, 0xbe, 0xf2, 0xca, 0xce, 0x50, 0xb4, 0x39, + 0x4a, 0x4a, 0x33, 0xdd, 0xb0, 0x18, 0x67, 0xe7, 0xe2, 0x38, 0x56, 0xd9, 0xe6, 0x03, 0x1f, 0x3b, + 0x76, 0x7a, 0xda, 0x2e, 0x1f, 0xc2, 0xe5, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x32, 0x45, + 0x30, 0xb4, 0x02, 0x00, 0x00, } diff --git a/transport/internet/config.proto b/transport/internet/config.proto index d44a6b8a..f98dabea 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -5,14 +5,14 @@ option go_package = "internet"; option java_package = "com.v2ray.core.transport.internet"; import "v2ray.com/core/common/net/network.proto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; message NetworkSettings { // Type of network that this settings supports. v2ray.core.common.net.Network network = 1; // Specific settings. - v2ray.core.common.loader.TypedSettings settings = 2; + v2ray.core.common.serial.TypedMessage settings = 2; } message StreamConfig { @@ -24,7 +24,7 @@ message StreamConfig { // Type of security. Must be a message name of the settings proto. string security_type = 3; - repeated v2ray.core.common.loader.TypedSettings security_settings = 4; + repeated v2ray.core.common.serial.TypedMessage security_settings = 4; } message ProxyConfig { diff --git a/transport/internet/header_test.go b/transport/internet/header_test.go index c9690558..e55af3c8 100644 --- a/transport/internet/header_test.go +++ b/transport/internet/header_test.go @@ -3,7 +3,7 @@ package internet_test import ( "testing" - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/testing/assert" . "v2ray.com/core/transport/internet" "v2ray.com/core/transport/internet/headers/noop" @@ -14,15 +14,15 @@ import ( func TestAllHeadersLoadable(t *testing.T) { assert := assert.On(t) - noopAuth, err := CreatePacketHeader(loader.GetType(new(noop.Config)), nil) + noopAuth, err := CreatePacketHeader(serial.GetMessageType(new(noop.Config)), nil) assert.Error(err).IsNil() assert.Int(noopAuth.Size()).Equals(0) - srtp, err := CreatePacketHeader(loader.GetType(new(srtp.Config)), nil) + srtp, err := CreatePacketHeader(serial.GetMessageType(new(srtp.Config)), nil) assert.Error(err).IsNil() assert.Int(srtp.Size()).Equals(4) - utp, err := CreatePacketHeader(loader.GetType(new(utp.Config)), nil) + utp, err := CreatePacketHeader(serial.GetMessageType(new(utp.Config)), nil) assert.Error(err).IsNil() assert.Int(utp.Size()).Equals(4) } diff --git a/transport/internet/headers/http/http.go b/transport/internet/headers/http/http.go index 8b85d23e..f506eb4b 100644 --- a/transport/internet/headers/http/http.go +++ b/transport/internet/headers/http/http.go @@ -9,7 +9,6 @@ import ( "time" "v2ray.com/core/common/buf" - "v2ray.com/core/common/loader" "v2ray.com/core/common/serial" "v2ray.com/core/transport/internet" ) @@ -255,5 +254,5 @@ func (HttpAuthenticatorFactory) Create(config interface{}) internet.ConnectionAu } func init() { - internet.RegisterConnectionAuthenticator(loader.GetType(new(Config)), HttpAuthenticatorFactory{}) + internet.RegisterConnectionAuthenticator(serial.GetMessageType(new(Config)), HttpAuthenticatorFactory{}) } diff --git a/transport/internet/headers/noop/noop.go b/transport/internet/headers/noop/noop.go index 4f0ed594..600ce137 100644 --- a/transport/internet/headers/noop/noop.go +++ b/transport/internet/headers/noop/noop.go @@ -3,7 +3,7 @@ package noop import ( "net" - "v2ray.com/core/common/loader" + "v2ray.com/core/common/serial" "v2ray.com/core/transport/internet" ) @@ -39,6 +39,6 @@ func (NoOpConnectionHeaderFactory) Create(config interface{}) internet.Connectio } func init() { - internet.RegisterPacketHeader(loader.GetType(new(Config)), NoOpHeaderFactory{}) - internet.RegisterConnectionAuthenticator(loader.GetType(new(Config)), NoOpConnectionHeaderFactory{}) + internet.RegisterPacketHeader(serial.GetMessageType(new(Config)), NoOpHeaderFactory{}) + internet.RegisterConnectionAuthenticator(serial.GetMessageType(new(Config)), NoOpConnectionHeaderFactory{}) } diff --git a/transport/internet/headers/srtp/srtp.go b/transport/internet/headers/srtp/srtp.go index 1d9e8fba..c4445e81 100644 --- a/transport/internet/headers/srtp/srtp.go +++ b/transport/internet/headers/srtp/srtp.go @@ -3,7 +3,6 @@ package srtp import ( "math/rand" - "v2ray.com/core/common/loader" "v2ray.com/core/common/serial" "v2ray.com/core/transport/internet" ) @@ -35,5 +34,5 @@ func (v SRTPFactory) Create(rawSettings interface{}) internet.PacketHeader { } func init() { - internet.RegisterPacketHeader(loader.GetType(new(Config)), SRTPFactory{}) + internet.RegisterPacketHeader(serial.GetMessageType(new(Config)), SRTPFactory{}) } diff --git a/transport/internet/headers/utp/utp.go b/transport/internet/headers/utp/utp.go index 24aac55d..329e5286 100644 --- a/transport/internet/headers/utp/utp.go +++ b/transport/internet/headers/utp/utp.go @@ -3,7 +3,6 @@ package utp import ( "math/rand" - "v2ray.com/core/common/loader" "v2ray.com/core/common/serial" "v2ray.com/core/transport/internet" ) @@ -36,5 +35,5 @@ func (v UTPFactory) Create(rawSettings interface{}) internet.PacketHeader { } func init() { - internet.RegisterPacketHeader(loader.GetType(new(Config)), UTPFactory{}) + internet.RegisterPacketHeader(serial.GetMessageType(new(Config)), UTPFactory{}) } diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index 70d8ce60..d390322f 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -23,7 +23,7 @@ package kcp import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -106,15 +106,15 @@ func (*ConnectionReuse) ProtoMessage() {} func (*ConnectionReuse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } type Config struct { - Mtu *MTU `protobuf:"bytes,1,opt,name=mtu" json:"mtu,omitempty"` - Tti *TTI `protobuf:"bytes,2,opt,name=tti" json:"tti,omitempty"` - UplinkCapacity *UplinkCapacity `protobuf:"bytes,3,opt,name=uplink_capacity,json=uplinkCapacity" json:"uplink_capacity,omitempty"` - DownlinkCapacity *DownlinkCapacity `protobuf:"bytes,4,opt,name=downlink_capacity,json=downlinkCapacity" json:"downlink_capacity,omitempty"` - Congestion bool `protobuf:"varint,5,opt,name=congestion" json:"congestion,omitempty"` - WriteBuffer *WriteBuffer `protobuf:"bytes,6,opt,name=write_buffer,json=writeBuffer" json:"write_buffer,omitempty"` - ReadBuffer *ReadBuffer `protobuf:"bytes,7,opt,name=read_buffer,json=readBuffer" json:"read_buffer,omitempty"` - HeaderConfig *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,8,opt,name=header_config,json=headerConfig" json:"header_config,omitempty"` - ConnectionReuse *ConnectionReuse `protobuf:"bytes,9,opt,name=connection_reuse,json=connectionReuse" json:"connection_reuse,omitempty"` + Mtu *MTU `protobuf:"bytes,1,opt,name=mtu" json:"mtu,omitempty"` + Tti *TTI `protobuf:"bytes,2,opt,name=tti" json:"tti,omitempty"` + UplinkCapacity *UplinkCapacity `protobuf:"bytes,3,opt,name=uplink_capacity,json=uplinkCapacity" json:"uplink_capacity,omitempty"` + DownlinkCapacity *DownlinkCapacity `protobuf:"bytes,4,opt,name=downlink_capacity,json=downlinkCapacity" json:"downlink_capacity,omitempty"` + Congestion bool `protobuf:"varint,5,opt,name=congestion" json:"congestion,omitempty"` + WriteBuffer *WriteBuffer `protobuf:"bytes,6,opt,name=write_buffer,json=writeBuffer" json:"write_buffer,omitempty"` + ReadBuffer *ReadBuffer `protobuf:"bytes,7,opt,name=read_buffer,json=readBuffer" json:"read_buffer,omitempty"` + HeaderConfig *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,8,opt,name=header_config,json=headerConfig" json:"header_config,omitempty"` + ConnectionReuse *ConnectionReuse `protobuf:"bytes,9,opt,name=connection_reuse,json=connectionReuse" json:"connection_reuse,omitempty"` } func (m *Config) Reset() { *m = Config{} } @@ -164,7 +164,7 @@ func (m *Config) GetReadBuffer() *ReadBuffer { return nil } -func (m *Config) GetHeaderConfig() *v2ray_core_common_loader.TypedSettings { +func (m *Config) GetHeaderConfig() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.HeaderConfig } @@ -192,35 +192,35 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/transport/internet/kcp/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 473 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x93, 0xd1, 0x6f, 0xd3, 0x30, - 0x10, 0xc6, 0x35, 0xba, 0x96, 0x71, 0xd9, 0xd6, 0x12, 0x21, 0x14, 0x81, 0x84, 0xb6, 0x4a, 0x6c, - 0xe3, 0x01, 0x47, 0x74, 0x2f, 0xf0, 0xda, 0xf2, 0x32, 0x89, 0x21, 0x30, 0xa9, 0x90, 0x26, 0xa1, - 0xe2, 0x3a, 0xd7, 0x62, 0xb5, 0xb1, 0x2d, 0xc7, 0x59, 0x55, 0xfe, 0x24, 0xfe, 0x4a, 0x64, 0xa7, - 0x5d, 0xdb, 0x48, 0xdb, 0xf2, 0x96, 0xf8, 0xbe, 0xfb, 0xd9, 0xfa, 0xee, 0x3b, 0xe8, 0xdd, 0xf6, - 0x0c, 0x5b, 0x12, 0xae, 0xb2, 0x98, 0x2b, 0x83, 0xb1, 0x35, 0x4c, 0xe6, 0x5a, 0x19, 0x1b, 0x0b, - 0x69, 0xd1, 0x48, 0xb4, 0xf1, 0x8c, 0xeb, 0x98, 0x2b, 0x39, 0x11, 0x53, 0xa2, 0x8d, 0xb2, 0x2a, - 0x3c, 0x5d, 0xf7, 0x18, 0x24, 0x77, 0x7a, 0xb2, 0xd6, 0x93, 0x19, 0xd7, 0xaf, 0xce, 0x2b, 0x58, - 0xae, 0xb2, 0x4c, 0xc9, 0x78, 0xae, 0x58, 0x8a, 0x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xed, 0xa4, 0xd5, - 0x11, 0xbe, 0x01, 0xe0, 0x4a, 0x4e, 0x31, 0x77, 0x3e, 0x47, 0x4d, 0x6f, 0xec, 0xd6, 0x49, 0xf8, - 0x1d, 0x0e, 0x17, 0x6e, 0x98, 0xa3, 0xb1, 0x9f, 0x55, 0xd4, 0xf2, 0x97, 0x93, 0x1a, 0x97, 0x6f, - 0x65, 0x80, 0x06, 0x8b, 0xad, 0x40, 0x7c, 0x85, 0xc0, 0x20, 0x4b, 0xd7, 0xc4, 0xa7, 0x9e, 0xf8, - 0xbe, 0x06, 0x71, 0x13, 0x19, 0x0a, 0x66, 0x13, 0x9f, 0x2f, 0x70, 0xf4, 0x07, 0xdd, 0x42, 0x8c, - 0xca, 0xf5, 0x8a, 0x0e, 0x3c, 0xf1, 0x7c, 0x9b, 0x58, 0x2e, 0x0e, 0x29, 0x17, 0x87, 0x24, 0x4b, - 0x8d, 0xe9, 0x0f, 0xb4, 0x56, 0xc8, 0x69, 0x4e, 0x0f, 0xcb, 0xee, 0x55, 0x84, 0x7e, 0x41, 0x87, - 0xdf, 0x05, 0x6f, 0x64, 0x5c, 0xf2, 0xa2, 0x67, 0x1e, 0xd8, 0xab, 0xf1, 0xc4, 0x4a, 0x66, 0x69, - 0x9b, 0xef, 0x1e, 0xf4, 0x3f, 0xc1, 0x5b, 0xae, 0xb2, 0xc7, 0x49, 0xfd, 0xa0, 0x7c, 0xcf, 0x37, - 0xb7, 0xde, 0x37, 0x8d, 0x19, 0xd7, 0xe3, 0x96, 0x5f, 0xf5, 0xcb, 0xff, 0x01, 0x00, 0x00, 0xff, - 0xff, 0x76, 0x78, 0x1a, 0x9c, 0x6c, 0x04, 0x00, 0x00, + // 472 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x53, 0x5d, 0x6f, 0xd3, 0x30, + 0x14, 0xd5, 0xe8, 0x5a, 0xc6, 0xcd, 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, 0x5f, 0xc8, 0x32, 0xd4, 0xa9, 0xef, 0x59, 0x74, 0xf4, 0xaf, 0x89, 0xbe, 0x41, 0xc4, 0x37, + 0x88, 0x24, 0xb6, 0x41, 0x43, 0x5f, 0x20, 0x7a, 0xec, 0x97, 0x57, 0x09, 0xfa, 0x01, 0x1d, 0x7e, + 0x97, 0xbb, 0x54, 0xdb, 0xe0, 0x45, 0x4f, 0x1c, 0x5f, 0xaf, 0xc6, 0x0b, 0xf7, 0x22, 0x4b, 0xdb, + 0x7c, 0xf7, 0xa0, 0xff, 0x11, 0x5e, 0x73, 0x95, 0x3f, 0xcc, 0xd4, 0x0f, 0xfc, 0x7b, 0xbe, 0xda, + 0x76, 0xdf, 0x34, 0x66, 0xbc, 0x18, 0xb7, 0x5c, 0xd3, 0xaf, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, + 0xc4, 0x62, 0x24, 0xb7, 0x74, 0x04, 0x00, 0x00, } diff --git a/transport/internet/kcp/config.proto b/transport/internet/kcp/config.proto index 6cdd8a6b..2c8c0da4 100644 --- a/transport/internet/kcp/config.proto +++ b/transport/internet/kcp/config.proto @@ -5,7 +5,7 @@ option go_package = "kcp"; option java_package = "com.v2ray.core.transport.internet.kcp"; option java_outer_classname = "ConfigProto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; // Maximum Transmission Unit, in bytes. message MTU { @@ -49,6 +49,6 @@ message Config { bool congestion = 5; WriteBuffer write_buffer = 6; ReadBuffer read_buffer = 7; - v2ray.core.common.loader.TypedSettings header_config = 8; + v2ray.core.common.serial.TypedMessage header_config = 8; ConnectionReuse connection_reuse = 9; } \ No newline at end of file diff --git a/transport/internet/kcp/kcp_test.go b/transport/internet/kcp/kcp_test.go index f7d50b47..08c5e236 100644 --- a/transport/internet/kcp/kcp_test.go +++ b/transport/internet/kcp/kcp_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/testing/assert" "v2ray.com/core/transport/internet" . "v2ray.com/core/transport/internet/kcp" @@ -24,7 +24,7 @@ func TestDialAndListen(t *testing.T) { NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_KCP, - Settings: loader.NewTypedSettings(&Config{}), + Settings: serial.ToTypedMessage(&Config{}), }, }, }, @@ -63,7 +63,7 @@ func TestDialAndListen(t *testing.T) { NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_KCP, - Settings: loader.NewTypedSettings(&Config{}), + Settings: serial.ToTypedMessage(&Config{}), }, }, }, diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index 20a2f739..e75222cf 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -17,7 +17,7 @@ package tcp import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import v2ray_core_common_loader "v2ray.com/core/common/loader" +import v2ray_core_common_serial "v2ray.com/core/common/serial" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -40,8 +40,8 @@ func (*ConnectionReuse) ProtoMessage() {} func (*ConnectionReuse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } type Config struct { - ConnectionReuse *ConnectionReuse `protobuf:"bytes,1,opt,name=connection_reuse,json=connectionReuse" json:"connection_reuse,omitempty"` - HeaderSettings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,2,opt,name=header_settings,json=headerSettings" json:"header_settings,omitempty"` + ConnectionReuse *ConnectionReuse `protobuf:"bytes,1,opt,name=connection_reuse,json=connectionReuse" json:"connection_reuse,omitempty"` + HeaderSettings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,opt,name=header_settings,json=headerSettings" json:"header_settings,omitempty"` } func (m *Config) Reset() { *m = Config{} } @@ -56,7 +56,7 @@ func (m *Config) GetConnectionReuse() *ConnectionReuse { return nil } -func (m *Config) GetHeaderSettings() *v2ray_core_common_loader.TypedSettings { +func (m *Config) GetHeaderSettings() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.HeaderSettings } @@ -71,21 +71,22 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/transport/internet/tcp/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 249 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x90, 0xc1, 0x4a, 0xc3, 0x60, - 0x10, 0x84, 0x89, 0x42, 0x90, 0xbf, 0x60, 0x24, 0x07, 0x29, 0x9e, 0xb4, 0x20, 0xd5, 0xcb, 0xfe, - 0x10, 0x4f, 0x5e, 0xdb, 0x17, 0x28, 0xd1, 0x93, 0x20, 0x25, 0xdd, 0xae, 0x35, 0xd0, 0xec, 0xfe, - 0x6c, 0x56, 0x21, 0x8f, 0xe6, 0xdb, 0x49, 0x92, 0xa6, 0x94, 0x5c, 0x7a, 0x5c, 0x98, 0x99, 0xfd, - 0x66, 0x5c, 0xf6, 0x9b, 0x69, 0xd1, 0x00, 0x4a, 0xe5, 0x51, 0x94, 0xbc, 0x69, 0xc1, 0x75, 0x10, - 0x35, 0x5f, 0xb2, 0x91, 0x32, 0x99, 0x37, 0x0c, 0x1e, 0x85, 0xbf, 0xca, 0x1d, 0x04, 0x15, 0x93, - 0xf4, 0x61, 0xf0, 0x28, 0xc1, 0x51, 0x0f, 0x83, 0x1e, 0x0c, 0xc3, 0xdd, 0x7c, 0x14, 0x8b, 0x52, - 0x55, 0xc2, 0x7e, 0x2f, 0xc5, 0x96, 0xd4, 0x5b, 0x13, 0xa8, 0xcf, 0x9a, 0x3d, 0xbb, 0x64, 0x29, - 0xcc, 0x84, 0x56, 0x0a, 0xe7, 0xf4, 0x53, 0x53, 0x7a, 0xeb, 0x62, 0xe2, 0x62, 0xb3, 0xa7, 0x69, - 0x74, 0x1f, 0x3d, 0x5d, 0xe5, 0x87, 0x6b, 0xf6, 0x17, 0xb9, 0x78, 0xd9, 0x71, 0xa4, 0x9f, 0xee, - 0x06, 0x8f, 0xae, 0xb5, 0xb6, 0xb6, 0x4e, 0x3c, 0xc9, 0x32, 0x38, 0x0b, 0x07, 0xa3, 0x87, 0x79, - 0x82, 0x23, 0x82, 0x95, 0x4b, 0xbe, 0xa9, 0x25, 0x5d, 0xd7, 0x64, 0x56, 0xf2, 0xae, 0x9e, 0x5e, - 0x74, 0xe9, 0xf3, 0xd3, 0xf4, 0xbe, 0x13, 0xf4, 0x9d, 0xe0, 0xbd, 0x09, 0xb4, 0x7d, 0x3b, 0xc8, - 0xf3, 0xeb, 0xde, 0x3f, 0xdc, 0x8b, 0x57, 0xf7, 0x88, 0x52, 0x9d, 0x67, 0x5b, 0x4c, 0xfa, 0x86, - 0xab, 0x76, 0x9c, 0x8f, 0x4b, 0xc3, 0xb0, 0x89, 0xbb, 0xa1, 0x5e, 0xfe, 0x03, 0x00, 0x00, 0xff, - 0xff, 0xdf, 0xaf, 0x5e, 0x9f, 0xaa, 0x01, 0x00, 0x00, + // 257 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x90, 0x41, 0x4b, 0xc3, 0x40, + 0x10, 0x85, 0x89, 0x42, 0x90, 0x2d, 0x18, 0xc9, 0x41, 0x8a, 0x27, 0x2d, 0x28, 0x7a, 0xd9, 0x95, + 0x78, 0xf2, 0xda, 0x9e, 0x45, 0x89, 0x9e, 0x04, 0x09, 0xdb, 0xe9, 0x18, 0x03, 0xdd, 0x9d, 0x65, + 0x76, 0x14, 0xfa, 0xcf, 0xfc, 0x79, 0x92, 0x6c, 0x5b, 0x24, 0x97, 0x1e, 0x17, 0xde, 0xf7, 0xf6, + 0x7d, 0xa3, 0xaa, 0x9f, 0x8a, 0xed, 0x46, 0x03, 0x39, 0x03, 0xc4, 0x68, 0x84, 0xad, 0x8f, 0x81, + 0x58, 0x4c, 0xe7, 0x05, 0xd9, 0xa3, 0x18, 0x81, 0x60, 0x80, 0xfc, 0x67, 0xd7, 0xea, 0xc0, 0x24, + 0x54, 0x5e, 0xed, 0x18, 0x46, 0xbd, 0xcf, 0xeb, 0x5d, 0x5e, 0x0b, 0x84, 0x8b, 0xfb, 0x51, 0x2d, + 0x90, 0x73, 0xe4, 0x4d, 0x44, 0xee, 0xec, 0xda, 0xc8, 0x26, 0xe0, 0xaa, 0x71, 0x18, 0xa3, 0x6d, + 0x31, 0x95, 0xce, 0xee, 0x54, 0xb1, 0x20, 0xef, 0x11, 0xa4, 0x23, 0x5f, 0xe3, 0x77, 0xc4, 0xf2, + 0x5c, 0xe5, 0xe8, 0xed, 0x72, 0x8d, 0xd3, 0xec, 0x32, 0xbb, 0x3d, 0xa9, 0xb7, 0xaf, 0xd9, 0x6f, + 0xa6, 0xf2, 0xc5, 0x30, 0xa8, 0xfc, 0x50, 0x67, 0xb0, 0xa7, 0x1a, 0xee, 0xb1, 0x21, 0x3c, 0xa9, + 0x2a, 0x7d, 0x70, 0xa5, 0x1e, 0x7d, 0x58, 0x17, 0x30, 0x5a, 0xf0, 0xac, 0x8a, 0x2f, 0xb4, 0x2b, + 0xe4, 0x26, 0xa2, 0x48, 0xe7, 0xdb, 0x38, 0x3d, 0x1a, 0xda, 0x6f, 0xfe, 0xb7, 0x27, 0x39, 0x9d, + 0xe4, 0xf4, 0x5b, 0x2f, 0xf7, 0x94, 0xdc, 0xea, 0xd3, 0x84, 0xbf, 0x6e, 0xe9, 0xf9, 0xa3, 0xba, + 0x06, 0x72, 0x87, 0xa7, 0xcd, 0x27, 0x49, 0xf0, 0xa5, 0xbf, 0xcd, 0xfb, 0xb1, 0x40, 0x58, 0xe6, + 0xc3, 0x9d, 0x1e, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, 0x15, 0x9d, 0x12, 0x13, 0xb2, 0x01, 0x00, + 0x00, } diff --git a/transport/internet/tcp/config.proto b/transport/internet/tcp/config.proto index 296095eb..c99aed50 100644 --- a/transport/internet/tcp/config.proto +++ b/transport/internet/tcp/config.proto @@ -5,12 +5,12 @@ option go_package = "tcp"; option java_package = "com.v2ray.core.transport.internet.tcp"; option java_outer_classname = "ConfigProto"; -import "v2ray.com/core/common/loader/type.proto"; +import "v2ray.com/core/common/serial/typed_message.proto"; message ConnectionReuse { bool enable = 1; } message Config { ConnectionReuse connection_reuse = 1; - v2ray.core.common.loader.TypedSettings header_settings = 2; + v2ray.core.common.serial.TypedMessage header_settings = 2; } \ No newline at end of file diff --git a/transport/internet/ws/ws_test.go b/transport/internet/ws/ws_test.go index c15eeb19..441d480a 100644 --- a/transport/internet/ws/ws_test.go +++ b/transport/internet/ws/ws_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "v2ray.com/core/common/loader" v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/serial" "v2ray.com/core/testing/assert" "v2ray.com/core/transport/internet" v2tls "v2ray.com/core/transport/internet/tls" @@ -21,7 +21,7 @@ func Test_listenWSAndDial(t *testing.T) { NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_WebSocket, - Settings: loader.NewTypedSettings(&Config{ + Settings: serial.ToTypedMessage(&Config{ Path: "ws", }), }, @@ -47,7 +47,7 @@ func Test_listenWSAndDial(t *testing.T) { NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_WebSocket, - Settings: loader.NewTypedSettings(&Config{ + Settings: serial.ToTypedMessage(&Config{ Path: "ws", }), }, @@ -63,7 +63,7 @@ func Test_listenWSAndDial(t *testing.T) { NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_WebSocket, - Settings: loader.NewTypedSettings(&Config{ + Settings: serial.ToTypedMessage(&Config{ Path: "ws", }), }, @@ -79,7 +79,7 @@ func Test_listenWSAndDial(t *testing.T) { NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_WebSocket, - Settings: loader.NewTypedSettings(&Config{ + Settings: serial.ToTypedMessage(&Config{ Path: "ws", }), }, @@ -108,13 +108,13 @@ func Test_listenWSAndDial_TLS(t *testing.T) { listen, err := ListenWS(v2net.DomainAddress("localhost"), 13143, internet.ListenOptions{ Stream: &internet.StreamConfig{ - SecurityType: loader.GetType(new(v2tls.Config)), - SecuritySettings: []*loader.TypedSettings{loader.NewTypedSettings(tlsSettings)}, + SecurityType: serial.GetMessageType(new(v2tls.Config)), + SecuritySettings: []*serial.TypedMessage{serial.ToTypedMessage(tlsSettings)}, Network: v2net.Network_WebSocket, NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_WebSocket, - Settings: loader.NewTypedSettings(&Config{ + Settings: serial.ToTypedMessage(&Config{ Path: "wss", ConnectionReuse: &ConnectionReuse{ Enable: true, @@ -133,13 +133,13 @@ func Test_listenWSAndDial_TLS(t *testing.T) { }() conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13143), internet.DialerOptions{ Stream: &internet.StreamConfig{ - SecurityType: loader.GetType(new(v2tls.Config)), - SecuritySettings: []*loader.TypedSettings{loader.NewTypedSettings(tlsSettings)}, + SecurityType: serial.GetMessageType(new(v2tls.Config)), + SecuritySettings: []*serial.TypedMessage{serial.ToTypedMessage(tlsSettings)}, Network: v2net.Network_WebSocket, NetworkSettings: []*internet.NetworkSettings{ { Network: v2net.Network_WebSocket, - Settings: loader.NewTypedSettings(&Config{ + Settings: serial.ToTypedMessage(&Config{ Path: "wss", ConnectionReuse: &ConnectionReuse{ Enable: true,