1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-25 00:45:24 +00:00

implement ss2022 client timestamp check as per spec

This commit is contained in:
Shelikhoo 2023-11-18 23:20:27 +00:00 committed by Xiaokang Wang (Shelikhoo)
parent d8e32f17bd
commit 8a1777ce62
2 changed files with 10 additions and 1 deletions

View File

@ -73,6 +73,15 @@ func (c *ClientUDPSession) KeepReading() {
newError("unable to decode udp response").Base(err).WriteToLog()
continue
}
{
timeDifference := int64(udpResp.TimeStamp) - time.Now().Unix()
if timeDifference < -30 || timeDifference > 30 {
newError("udp packet timestamp difference too large, packet discarded").WriteToLog()
continue
}
}
c.locker.Lock()
session, ok := c.sessionMap[string(udpResp.ClientSessionID[:])]
if ok {

View File

@ -203,7 +203,7 @@ func (t *TCPRequest) DecodeTCPResponseHeader(effectivePsk []byte, In io.Reader)
return newError("unexpected TCP header type")
}
timeDifference := int64(fixedLengthHeader.Timestamp) - time.Now().Unix()
if timeDifference < -60 || timeDifference > 60 {
if timeDifference < -30 || timeDifference > 30 {
return newError("timestamp is too far away")
}