Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Apr 27, 2017
1 parent b841042 commit 2e756cd
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/dns/server/nameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (v *UDPNameServer) AssignUnusedID(response chan<- *ARecord) uint16 {
}

for {
id = dice.RandomUint16()
id = dice.RollUint16()
if _, found := v.requests[id]; found {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions common/dice/dice.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func Roll(n int) int {
return rand.Intn(n)
}

// RandomUint16 returns a random uint16 value.
func RandomUint16() uint16 {
// RollUint16 returns a random uint16 value.
func RollUint16() uint16 {
return uint16(rand.Intn(65536))
}

Expand Down
2 changes: 1 addition & 1 deletion transport/internet/headers/srtp/srtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *SRTP) Write(b []byte) (int, error) {
func NewSRTP(ctx context.Context, config interface{}) (interface{}, error) {
return &SRTP{
header: 0xB5E8,
number: dice.RandomUint16(),
number: dice.RollUint16(),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion transport/internet/headers/utp/utp.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewUTP(ctx context.Context, config interface{}) (interface{}, error) {
return &UTP{
header: 1,
extension: 0,
connectionId: dice.RandomUint16(),
connectionId: dice.RollUint16(),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion transport/internet/headers/wechat/wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (vc *VideoChat) Write(b []byte) (int, error) {

func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
return &VideoChat{
sn: int(dice.RandomUint16()),
sn: int(dice.RollUint16()),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion transport/internet/kcp/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
globalConv = uint32(dice.RandomUint16())
globalConv = uint32(dice.RollUint16())
)

type ClientConnection struct {
Expand Down
2 changes: 1 addition & 1 deletion v2ray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func TestV2RayClose(t *testing.T) {
assert := assert.On(t)

port := v2net.Port(dice.RandomUint16())
port := v2net.Port(dice.RollUint16())
config := &Config{
Inbound: []*proxyman.InboundHandlerConfig{
{
Expand Down

0 comments on commit 2e756cd

Please sign in to comment.