Skip to content

Commit b57f305

Browse files
committed
chore: speedup convid generation
1 parent 3a1caf1 commit b57f305

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

transport/kcptun/client.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package kcptun
22

33
import (
44
"context"
5-
"crypto/rand"
6-
"encoding/binary"
75
"net"
86
"sync"
97
"time"
108

119
"github.com/metacubex/mihomo/log"
1210

1311
"github.com/metacubex/kcp-go"
12+
"github.com/metacubex/randv2"
1413
"github.com/metacubex/smux"
1514
)
1615

@@ -60,8 +59,7 @@ func (c *Client) createConn(ctx context.Context, dial DialFn) (*smux.Session, er
6059
}
6160

6261
config := c.config
63-
var convid uint32
64-
binary.Read(rand.Reader, binary.LittleEndian, &convid)
62+
convid := randv2.Uint32()
6563
kcpconn, err := kcp.NewConn4(convid, addr, c.block, config.DataShard, config.ParityShard, true, conn)
6664
if err != nil {
6765
return nil, err

0 commit comments

Comments
 (0)