1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-30 07:40:25 +08:00

增加抗重放攻击

This commit is contained in:
源文雨
2022-05-15 23:08:29 +08:00
parent 90a1b5f3e4
commit 764d0f61d6
4 changed files with 26 additions and 10 deletions

View File

@@ -45,6 +45,8 @@ type Me struct {
writer *helper.Writer
// 本机未接收完全分片池
recving *ttl.Cache[[32]byte, *head.Packet]
// 抗重放攻击记录池
recved *ttl.Cache[uint64, uint8]
// 本机上层配置
srcport, dstport, mtu uint16
}
@@ -96,7 +98,8 @@ func NewMe(cfg *MyConfig) (m Me) {
if m.writer == nil {
m.writer = helper.SelectWriter()
}
m.recving = ttl.NewCache[[32]byte, *head.Packet](time.Second * 128)
m.recving = ttl.NewCache[[32]byte, *head.Packet](time.Second * 30)
m.recved = ttl.NewCache[uint64, uint8](time.Second * 30)
return
}