mirror of https://github.com/v2ray/v2ray-core
leverage dice.Roll
parent
71c9bd678c
commit
98cc28a4c4
|
@ -1,13 +1,13 @@
|
|||
package dns
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/v2ray/v2ray-core/app/dispatcher"
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
"github.com/v2ray/v2ray-core/common/dice"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/transport/internet/udp"
|
||||
|
@ -84,7 +84,7 @@ func (this *UDPNameServer) AssignUnusedID(response chan<- *ARecord) uint16 {
|
|||
}
|
||||
|
||||
for {
|
||||
id = uint16(rand.Intn(65536))
|
||||
id = uint16(dice.Roll(65536))
|
||||
if _, found := this.requests[id]; found {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package protocol
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/dice"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
)
|
||||
|
||||
|
@ -21,7 +21,7 @@ func NowTime() Timestamp {
|
|||
|
||||
func NewTimestampGenerator(base Timestamp, delta int) TimestampGenerator {
|
||||
return func() Timestamp {
|
||||
rangeInDelta := rand.Intn(delta*2) - delta
|
||||
rangeInDelta := dice.Roll(delta*2) - delta
|
||||
return base + Timestamp(rangeInDelta)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package kcp
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"net"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/dice"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/transport/internet"
|
||||
|
@ -18,7 +18,7 @@ func DialKCP(src v2net.Address, dest v2net.Destination) (internet.Connection, er
|
|||
}
|
||||
|
||||
cpip := NewSimpleAuthenticator()
|
||||
session := NewConnection(uint16(rand.Uint32()), conn, conn.LocalAddr().(*net.UDPAddr), conn.RemoteAddr().(*net.UDPAddr), cpip)
|
||||
session := NewConnection(uint16(dice.Roll(65536)), conn, conn.LocalAddr().(*net.UDPAddr), conn.RemoteAddr().(*net.UDPAddr), cpip)
|
||||
session.FetchInputFrom(conn)
|
||||
|
||||
return session, nil
|
||||
|
|
Loading…
Reference in New Issue