From 9a44ff314586edca0dcad9b884de04435b2f2fc4 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 12 Jul 2016 18:54:16 +0200 Subject: [PATCH] static conv --- transport/internet/kcp/dialer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/transport/internet/kcp/dialer.go b/transport/internet/kcp/dialer.go index 0e0b3f14..c21ee780 100644 --- a/transport/internet/kcp/dialer.go +++ b/transport/internet/kcp/dialer.go @@ -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