mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-16 04:24:05 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59b0255d83 |
@@ -109,7 +109,7 @@ func (h *HealthPingRTTS) getStatistics() *HealthPingStats {
|
|||||||
stats.Min = 0
|
stats.Min = 0
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
stats.Average = time.Duration(int(sum) / cnt)
|
stats.Average = sum / time.Duration(cnt)
|
||||||
var std float64
|
var std float64
|
||||||
if cnt < 2 {
|
if cnt < 2 {
|
||||||
// no enough data for standard deviation, we assume it's half of the average rtt
|
// no enough data for standard deviation, we assume it's half of the average rtt
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func parsePlainUDPPacket(sessionID, packetID uint64, bodyPlain []byte) (DecodedU
|
|||||||
return DecodedUDPPacket{}, ErrBadHeaderType
|
return DecodedUDPPacket{}, ErrBadHeaderType
|
||||||
}
|
}
|
||||||
epoch := binary.BigEndian.Uint64(bodyPlain[1:9])
|
epoch := binary.BigEndian.Uint64(bodyPlain[1:9])
|
||||||
diff := int(math.Abs(float64(time.Now().Unix() - int64(epoch))))
|
diff := math.Abs(float64(time.Now().Unix() - int64(epoch)))
|
||||||
if diff > 30 {
|
if diff > 30 {
|
||||||
return DecodedUDPPacket{}, ErrBadTimestamp
|
return DecodedUDPPacket{}, ErrBadTimestamp
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ func (f *SlidingWindow) Add(counter uint64) {
|
|||||||
|
|
||||||
if counter > f.last {
|
if counter > f.last {
|
||||||
lastBlockIndex := f.last >> swBlockBitLog
|
lastBlockIndex := f.last >> swBlockBitLog
|
||||||
diff := int(blockIndex - lastBlockIndex)
|
diff := blockIndex - lastBlockIndex
|
||||||
if diff > swRingBlocks {
|
if diff > swRingBlocks {
|
||||||
diff = swRingBlocks
|
diff = swRingBlocks
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < diff; i++ {
|
for i := 0; i < int(diff); i++ {
|
||||||
lastBlockIndex = (lastBlockIndex + 1) & swBlockMask
|
lastBlockIndex = (lastBlockIndex + 1) & swBlockMask
|
||||||
f.ring[lastBlockIndex] = 0
|
f.ring[lastBlockIndex] = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ func ReadClientRequestHeaderWithFixed(reader *StreamReader, fixedChunk []byte) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
epoch := binary.BigEndian.Uint64(plainFixed[1:9])
|
epoch := binary.BigEndian.Uint64(plainFixed[1:9])
|
||||||
diff := int(math.Abs(float64(time.Now().Unix() - int64(epoch))))
|
diff := math.Abs(float64(time.Now().Unix() - int64(epoch)))
|
||||||
if diff > 30 {
|
if diff > 30 {
|
||||||
return nil, ErrBadTimestamp
|
return nil, ErrBadTimestamp
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,7 @@ func ReadTCPResponse(r io.Reader, method *CipherMethod, psk []byte, clientSalt [
|
|||||||
}
|
}
|
||||||
|
|
||||||
serverEpoch := binary.BigEndian.Uint64(decryptedFixed[1:9])
|
serverEpoch := binary.BigEndian.Uint64(decryptedFixed[1:9])
|
||||||
diff := int(math.Abs(float64(time.Now().Unix() - int64(serverEpoch))))
|
diff := math.Abs(float64(time.Now().Unix() - int64(serverEpoch)))
|
||||||
if diff > 30 {
|
if diff > 30 {
|
||||||
return nil, ErrBadTimestamp
|
return nil, ErrBadTimestamp
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func jitter(backoff time.Duration) time.Duration {
|
|||||||
if half <= 0 {
|
if half <= 0 {
|
||||||
return backoff
|
return backoff
|
||||||
}
|
}
|
||||||
return half + time.Duration(dice.Roll(int(half)))
|
return half + time.Duration(dice.RollInt63n(int64(half)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func rateLimited(payload []byte) bool {
|
func rateLimited(payload []byte) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user