1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-26 03:55:26 -05:00

network proto

This commit is contained in:
Darien Raymond
2016-09-20 10:44:44 +02:00
parent fbdb1e09d7
commit c518726910
21 changed files with 173 additions and 52 deletions

View File

@@ -73,13 +73,13 @@ func (this *DokodemoDoor) Start() error {
}
this.accepting = true
if this.config.Network.HasNetwork(v2net.TCPNetwork) {
if this.config.Network.HasNetwork(v2net.Network_TCP) {
err := this.ListenTCP()
if err != nil {
return err
}
}
if this.config.Network.HasNetwork(v2net.UDPNetwork) {
if this.config.Network.HasNetwork(v2net.Network_UDP) {
err := this.ListenUDP()
if err != nil {
return err

View File

@@ -56,7 +56,7 @@ func TestDokodemoTCP(t *testing.T) {
dokodemo := NewDokodemoDoor(&Config{
Address: v2net.LocalHostIP,
Port: tcpServer.Port,
Network: v2net.TCPNetwork.AsList(),
Network: v2net.Network_TCP.AsList(),
Timeout: 600,
}, space, &proxy.InboundHandlerMeta{
Address: v2net.LocalHostIP,
@@ -126,7 +126,7 @@ func TestDokodemoUDP(t *testing.T) {
dokodemo := NewDokodemoDoor(&Config{
Address: v2net.LocalHostIP,
Port: udpServer.Port,
Network: v2net.UDPNetwork.AsList(),
Network: v2net.Network_UDP.AsList(),
Timeout: 600,
}, space, &proxy.InboundHandlerMeta{
Address: v2net.LocalHostIP,

View File

@@ -58,7 +58,7 @@ func (this *FreedomConnection) ResolveIP(destination v2net.Destination) v2net.De
ip := ips[dice.Roll(len(ips))]
var newDest v2net.Destination
if destination.Network() == v2net.TCPNetwork {
if destination.Network() == v2net.Network_TCP {
newDest = v2net.TCPDestination(v2net.IPAddress(ip), destination.Port())
} else {
newDest = v2net.UDPDestination(v2net.IPAddress(ip), destination.Port())
@@ -112,7 +112,7 @@ func (this *FreedomConnection) Dispatch(destination v2net.Destination, payload *
var reader io.Reader = conn
timeout := this.timeout
if destination.Network() == v2net.UDPNetwork {
if destination.Network() == v2net.Network_UDP {
timeout = 16
}
if timeout > 0 {

View File

@@ -49,7 +49,7 @@ func (this *VMessOutboundHandler) Dispatch(target v2net.Destination, payload *al
log.Info("VMess|Outbound: Tunneling request to ", target, " via ", rec.Destination())
command := protocol.RequestCommandTCP
if target.Network() == v2net.UDPNetwork {
if target.Network() == v2net.Network_UDP {
command = protocol.RequestCommandUDP
}
request := &protocol.RequestHeader{