mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 18:17:52 -05:00
implement ss2022 client timestamp check as per spec
This commit is contained in:
parent
d8e32f17bd
commit
8a1777ce62
@ -73,6 +73,15 @@ func (c *ClientUDPSession) KeepReading() {
|
|||||||
newError("unable to decode udp response").Base(err).WriteToLog()
|
newError("unable to decode udp response").Base(err).WriteToLog()
|
||||||
continue
|
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()
|
c.locker.Lock()
|
||||||
session, ok := c.sessionMap[string(udpResp.ClientSessionID[:])]
|
session, ok := c.sessionMap[string(udpResp.ClientSessionID[:])]
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -203,7 +203,7 @@ func (t *TCPRequest) DecodeTCPResponseHeader(effectivePsk []byte, In io.Reader)
|
|||||||
return newError("unexpected TCP header type")
|
return newError("unexpected TCP header type")
|
||||||
}
|
}
|
||||||
timeDifference := int64(fixedLengthHeader.Timestamp) - time.Now().Unix()
|
timeDifference := int64(fixedLengthHeader.Timestamp) - time.Now().Unix()
|
||||||
if timeDifference < -60 || timeDifference > 60 {
|
if timeDifference < -30 || timeDifference > 30 {
|
||||||
return newError("timestamp is too far away")
|
return newError("timestamp is too far away")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user