mirror of https://github.com/v2ray/v2ray-core
update dtls.length logic
parent
f9277958a5
commit
956c4f5bcf
|
@ -11,6 +11,7 @@ import (
|
||||||
type DTLS struct {
|
type DTLS struct {
|
||||||
epoch uint16
|
epoch uint16
|
||||||
sequence uint32
|
sequence uint32
|
||||||
|
length uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
// Size implements PacketHeader.
|
// Size implements PacketHeader.
|
||||||
|
@ -29,9 +30,12 @@ func (d *DTLS) Write(b []byte) (int, error) {
|
||||||
b[6] = byte(d.sequence >> 8)
|
b[6] = byte(d.sequence >> 8)
|
||||||
b[7] = byte(d.sequence)
|
b[7] = byte(d.sequence)
|
||||||
d.sequence++
|
d.sequence++
|
||||||
l := dice.RollUint16()
|
b[8] = byte(d.length >> 8)
|
||||||
b[8] = byte(l >> 8)
|
b[9] = byte(d.length)
|
||||||
b[9] = byte(l)
|
d.length += 17
|
||||||
|
if d.length > 1024 {
|
||||||
|
d.length -= 1024
|
||||||
|
}
|
||||||
return 10, nil
|
return 10, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +44,7 @@ func New(ctx context.Context, config interface{}) (interface{}, error) {
|
||||||
return &DTLS{
|
return &DTLS{
|
||||||
epoch: dice.RollUint16(),
|
epoch: dice.RollUint16(),
|
||||||
sequence: 0,
|
sequence: 0,
|
||||||
|
length: uint16(dice.Roll(1024) + 100),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue