mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-03 07:56:42 -05:00
static conv
This commit is contained in:
parent
9434f5156c
commit
9a44ff3145
@ -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…
Reference in New Issue
Block a user