static conv

pull/215/head v1.19.1
v2ray 8 years ago
parent 9434f5156c
commit 9a44ff3145
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -2,6 +2,7 @@ package kcp
import (
"net"
"sync/atomic"
"github.com/v2ray/v2ray-core/common/dice"
"github.com/v2ray/v2ray-core/common/log"
@ -9,6 +10,10 @@ import (
"github.com/v2ray/v2ray-core/transport/internet"
)
var (
globalConv = uint32(dice.Roll(65536))
)
func DialKCP(src v2net.Address, dest v2net.Destination) (internet.Connection, error) {
udpDest := v2net.UDPDestination(dest.Address(), dest.Port())
log.Info("Dialling KCP to ", udpDest)
@ -18,7 +23,8 @@ func DialKCP(src v2net.Address, dest v2net.Destination) (internet.Connection, er
}
cpip := NewSimpleAuthenticator()
session := NewConnection(uint16(dice.Roll(65536)), conn, conn.LocalAddr().(*net.UDPAddr), conn.RemoteAddr().(*net.UDPAddr), cpip)
conv := uint16(atomic.AddUint32(&globalConv, 1))
session := NewConnection(conv, conn, conn.LocalAddr().(*net.UDPAddr), conn.RemoteAddr().(*net.UDPAddr), cpip)
session.FetchInputFrom(conn)
return session, nil

Loading…
Cancel
Save