1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-26 01:15:38 +00:00

Fix compatibility with Actinium

This commit is contained in:
Darien Raymond 2016-12-13 10:45:21 +01:00
parent a9790d59f0
commit 76da31c755
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
5 changed files with 29 additions and 15 deletions

View File

@ -39,6 +39,13 @@ func (v Security) Is(t SecurityType) bool {
return v == Security(t)
}
func NormSecurity(s Security) Security {
if s.Is(SecurityType_UNKNOWN) {
return Security(SecurityType_LEGACY)
}
return s
}
type RequestHeader struct {
Version byte
User *User
@ -100,5 +107,5 @@ func (v *SecurityConfig) AsSecurity() Security {
}
return Security(SecurityType_CHACHA20_POLY1305)
}
return Security(v.Type)
return NormSecurity(Security(v.Type))
}

View File

@ -35,26 +35,29 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type SecurityType int32
const (
SecurityType_NONE SecurityType = 0
SecurityType_UNKNOWN SecurityType = 0
SecurityType_LEGACY SecurityType = 1
SecurityType_AUTO SecurityType = 2
SecurityType_AES128_GCM SecurityType = 3
SecurityType_CHACHA20_POLY1305 SecurityType = 4
SecurityType_NONE SecurityType = 5
)
var SecurityType_name = map[int32]string{
0: "NONE",
0: "UNKNOWN",
1: "LEGACY",
2: "AUTO",
3: "AES128_GCM",
4: "CHACHA20_POLY1305",
5: "NONE",
}
var SecurityType_value = map[string]int32{
"NONE": 0,
"UNKNOWN": 0,
"LEGACY": 1,
"AUTO": 2,
"AES128_GCM": 3,
"CHACHA20_POLY1305": 4,
"NONE": 5,
}
func (x SecurityType) String() string {
@ -79,7 +82,7 @@ func init() {
func init() { proto.RegisterFile("v2ray.com/core/common/protocol/headers.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 227 bytes of a gzipped FileDescriptorProto
// 241 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x29, 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, 0xcf, 0x48, 0x4d, 0x4c, 0x49,
@ -87,12 +90,13 @@ var fileDescriptor0 = []byte{
0x54, 0x2a, 0xf9, 0x71, 0xf1, 0x05, 0xa7, 0x26, 0x97, 0x16, 0x65, 0x96, 0x54, 0x3a, 0xe7, 0xe7,
0xa5, 0x65, 0xa6, 0x0b, 0xd9, 0x70, 0xb1, 0x94, 0x54, 0x16, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x6a,
0xf0, 0x19, 0x69, 0xe8, 0xe1, 0xd6, 0xac, 0x07, 0xd3, 0x19, 0x52, 0x59, 0x90, 0x1a, 0x04, 0xd6,
0xa5, 0x15, 0xca, 0xc5, 0x83, 0x2c, 0x2a, 0xc4, 0xc1, 0xc5, 0xe2, 0xe7, 0xef, 0xe7, 0x2a, 0xc0,
0x20, 0xc4, 0xc5, 0xc5, 0xe6, 0xe3, 0xea, 0xee, 0xe8, 0x1c, 0x29, 0xc0, 0x08, 0x12, 0x75, 0x0c,
0x0d, 0xf1, 0x17, 0x60, 0x12, 0xe2, 0xe3, 0xe2, 0x72, 0x74, 0x0d, 0x36, 0x34, 0xb2, 0x88, 0x77,
0x77, 0xf6, 0x15, 0x60, 0x16, 0x12, 0xe5, 0x12, 0x74, 0xf6, 0x70, 0x74, 0xf6, 0x70, 0x34, 0x32,
0x88, 0x0f, 0xf0, 0xf7, 0x89, 0x34, 0x34, 0x36, 0x30, 0x15, 0x60, 0x71, 0xb2, 0xe0, 0x92, 0x4b,
0xce, 0xcf, 0xc5, 0xe3, 0x16, 0x27, 0x1e, 0x0f, 0x88, 0x9f, 0x03, 0x40, 0x02, 0x51, 0x1c, 0x30,
0xf1, 0x24, 0x36, 0x30, 0xcb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x1e, 0x65, 0x93, 0x33,
0x01, 0x00, 0x00,
0xa5, 0x95, 0xc4, 0xc5, 0x83, 0x2c, 0x2a, 0xc4, 0xcd, 0xc5, 0x1e, 0xea, 0xe7, 0xed, 0xe7, 0x1f,
0xee, 0x27, 0xc0, 0x20, 0xc4, 0xc5, 0xc5, 0xe6, 0xe3, 0xea, 0xee, 0xe8, 0x1c, 0x29, 0xc0, 0x28,
0xc4, 0xc1, 0xc5, 0xe2, 0x18, 0x1a, 0xe2, 0x2f, 0xc0, 0x24, 0xc4, 0xc7, 0xc5, 0xe5, 0xe8, 0x1a,
0x6c, 0x68, 0x64, 0x11, 0xef, 0xee, 0xec, 0x2b, 0xc0, 0x2c, 0x24, 0xca, 0x25, 0xe8, 0xec, 0xe1,
0xe8, 0xec, 0xe1, 0x68, 0x64, 0x10, 0x1f, 0xe0, 0xef, 0x13, 0x69, 0x68, 0x6c, 0x60, 0x2a, 0xc0,
0x02, 0xd2, 0xe0, 0xe7, 0xef, 0xe7, 0x2a, 0xc0, 0xea, 0x64, 0xc1, 0x25, 0x97, 0x9c, 0x9f, 0x8b,
0xc7, 0x61, 0x4e, 0x3c, 0x1e, 0x90, 0x00, 0x08, 0x00, 0x09, 0x44, 0x71, 0xc0, 0xc4, 0x93, 0xd8,
0xc0, 0x2c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xda, 0x88, 0xd8, 0x40, 0x01, 0x00,
0x00,
}

View File

@ -6,11 +6,12 @@ option java_package = "com.v2ray.core.common.protocol";
option java_outer_classname = "HeadersProto";
enum SecurityType {
NONE = 0;
UNKNOWN = 0;
LEGACY = 1;
AUTO = 2;
AES128_GCM = 3;
CHACHA20_POLY1305 = 4;
NONE = 5;
}
message SecurityConfig {

View File

@ -92,7 +92,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
v.responseHeader = buffer[33] // 1 byte
request.Option = protocol.RequestOption(buffer[34]) // 1 byte
padingLen := int(buffer[35] >> 4)
request.Security = protocol.Security(buffer[35] & 0x0F)
request.Security = protocol.NormSecurity(protocol.Security(buffer[35] & 0x0F))
// 1 bytes reserved
request.Command = protocol.RequestCommand(buffer[37])

View File

@ -187,6 +187,7 @@ func (v *VMessInboundHandler) HandleConnection(connection internet.Connection) {
go func() {
bodyReader := session.DecodeRequestBody(request, reader)
if err := buf.PipeUntilEOF(bodyReader, input); err != nil {
log.Debug("VMess|Inbound: Error when sending data to outbound: ", err)
connection.SetReusable(false)
}
bodyReader.Release()
@ -219,6 +220,7 @@ func (v *VMessInboundHandler) HandleConnection(connection internet.Connection) {
writer.SetCached(false)
if err := buf.PipeUntilEOF(output, bodyWriter); err != nil {
log.Debug("VMess|Inbound: Error when sending data to downstream: ", err)
connection.SetReusable(false)
}