1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-04 02:09:09 -04:00

separate network and transport protocol

This commit is contained in:
Darien Raymond
2017-01-12 12:54:34 +01:00
parent f9b3a1446a
commit d24fe9dbfb
41 changed files with 261 additions and 321 deletions

View File

@@ -13,10 +13,6 @@ func ParseNetwork(nwStr string) Network {
return Network_TCP
case "udp":
return Network_UDP
case "kcp":
return Network_KCP
case "ws":
return Network_WebSocket
default:
return Network_Unknown
}
@@ -32,7 +28,7 @@ func (v Network) SystemString() string {
switch v {
case Network_TCP:
return "tcp"
case Network_UDP, Network_KCP:
case Network_UDP:
return "udp"
default:
return "unknown"
@@ -45,10 +41,6 @@ func (v Network) URLPrefix() string {
return "tcp"
case Network_UDP:
return "udp"
case Network_KCP:
return "kcp"
case Network_WebSocket:
return "ws"
default:
return "unknown"
}

View File

@@ -16,10 +16,8 @@ const (
// Native TCP provided by system.
Network_RawTCP Network = 1
// V2Ray specific TCP.
Network_TCP Network = 2
Network_UDP Network = 3
Network_KCP Network = 4
Network_WebSocket Network = 5
Network_TCP Network = 2
Network_UDP Network = 3
)
var Network_name = map[int32]string{
@@ -27,16 +25,12 @@ var Network_name = map[int32]string{
1: "RawTCP",
2: "TCP",
3: "UDP",
4: "KCP",
5: "WebSocket",
}
var Network_value = map[string]int32{
"Unknown": 0,
"RawTCP": 1,
"TCP": 2,
"UDP": 3,
"KCP": 4,
"WebSocket": 5,
"Unknown": 0,
"RawTCP": 1,
"TCP": 2,
"UDP": 3,
}
func (x Network) String() string {
@@ -68,20 +62,18 @@ func init() {
func init() { proto.RegisterFile("v2ray.com/core/common/net/network.proto", fileDescriptor2) }
var fileDescriptor2 = []byte{
// 225 bytes of a gzipped FileDescriptorProto
// 203 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, 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x44, 0xc3,
0x8c, 0x82, 0x12, 0x2b, 0xf5, 0x9c, 0x41, 0x4a, 0x9d, 0x21, 0x4a, 0xfd, 0x52, 0x4b, 0x92, 0xd8,
0xc0, 0x01, 0x60, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x45, 0xf9, 0x86, 0x63, 0x2b, 0x01, 0x00,
0x00,
0xec, 0xe4, 0xc6, 0x25, 0x99, 0x9c, 0x9f, 0x8b, 0xdd, 0x1e, 0x27, 0x1e, 0xa8, 0xa1, 0x01, 0x20,
0x4f, 0x44, 0x31, 0xe7, 0xa5, 0x96, 0xac, 0x62, 0x12, 0x0d, 0x33, 0x0a, 0x4a, 0xac, 0xd4, 0x73,
0x06, 0x29, 0x75, 0x86, 0x28, 0xf5, 0x4b, 0x2d, 0x49, 0x62, 0x03, 0x7b, 0xd4, 0x18, 0x10, 0x00,
0x00, 0xff, 0xff, 0x3c, 0x17, 0x32, 0x51, 0x13, 0x01, 0x00, 0x00,
}

View File

@@ -16,12 +16,8 @@ enum Network {
TCP = 2;
UDP = 3;
KCP = 4;
WebSocket = 5;
}
message NetworkList {
repeated Network network = 1;
}
}

View File

@@ -3,7 +3,7 @@ package protocol
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import v2ray_core_common_net1 "v2ray.com/core/common/net"
import v2ray_core_common_net "v2ray.com/core/common/net"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
@@ -11,9 +11,9 @@ var _ = fmt.Errorf
var _ = math.Inf
type ServerEndpoint struct {
Address *v2ray_core_common_net1.IPOrDomain `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"`
User []*User `protobuf:"bytes,3,rep,name=user" json:"user,omitempty"`
Address *v2ray_core_common_net.IPOrDomain `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"`
User []*User `protobuf:"bytes,3,rep,name=user" json:"user,omitempty"`
}
func (m *ServerEndpoint) Reset() { *m = ServerEndpoint{} }
@@ -21,7 +21,7 @@ func (m *ServerEndpoint) String() string { return proto.CompactTextSt
func (*ServerEndpoint) ProtoMessage() {}
func (*ServerEndpoint) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} }
func (m *ServerEndpoint) GetAddress() *v2ray_core_common_net1.IPOrDomain {
func (m *ServerEndpoint) GetAddress() *v2ray_core_common_net.IPOrDomain {
if m != nil {
return m.Address
}