mirror of https://github.com/v2ray/v2ray-core
fix dtls header
parent
956c4f5bcf
commit
5b4eef5c7b
|
@ -16,7 +16,7 @@ type DTLS struct {
|
||||||
|
|
||||||
// Size implements PacketHeader.
|
// Size implements PacketHeader.
|
||||||
func (*DTLS) Size() int32 {
|
func (*DTLS) Size() int32 {
|
||||||
return 1 + 2 + 2 + 3 + 2
|
return 1 + 2 + 2 + 6 + 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write implements PacketHeader.
|
// Write implements PacketHeader.
|
||||||
|
@ -26,17 +26,20 @@ func (d *DTLS) Write(b []byte) (int, error) {
|
||||||
b[2] = 253
|
b[2] = 253
|
||||||
b[3] = byte(d.epoch >> 8)
|
b[3] = byte(d.epoch >> 8)
|
||||||
b[4] = byte(d.epoch)
|
b[4] = byte(d.epoch)
|
||||||
b[5] = byte(d.sequence >> 16)
|
b[5] = 0
|
||||||
b[6] = byte(d.sequence >> 8)
|
b[6] = 0
|
||||||
b[7] = byte(d.sequence)
|
b[7] = byte(d.sequence >> 24)
|
||||||
|
b[8] = byte(d.sequence >> 16)
|
||||||
|
b[9] = byte(d.sequence >> 8)
|
||||||
|
b[10] = byte(d.sequence)
|
||||||
d.sequence++
|
d.sequence++
|
||||||
b[8] = byte(d.length >> 8)
|
b[11] = byte(d.length >> 8)
|
||||||
b[9] = byte(d.length)
|
b[12] = byte(d.length)
|
||||||
d.length += 17
|
d.length += 17
|
||||||
if d.length > 1024 {
|
if d.length > 100 {
|
||||||
d.length -= 1024
|
d.length -= 50
|
||||||
}
|
}
|
||||||
return 10, nil
|
return 13, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new UTP header for the given config.
|
// New creates a new UTP header for the given config.
|
||||||
|
@ -44,7 +47,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),
|
length: 17,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue