feat: support ARC for DNS cache

This commit is contained in:
Larvan2
2023-12-02 17:07:36 +08:00
committed by wwqgtxx
parent bc74c943b8
commit 1a0932c210
24 changed files with 416 additions and 156 deletions

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"sync"
"github.com/metacubex/mihomo/common/cache"
"github.com/metacubex/mihomo/common/lru"
"github.com/metacubex/quic-go"
)
@@ -47,7 +47,7 @@ func fragWriteNative(quicConn quic.Connection, packet Packet, buf *bytes.Buffer,
}
type deFragger struct {
lru *cache.LruCache[uint16, *packetBag]
lru *lru.LruCache[uint16, *packetBag]
once sync.Once
}
@@ -63,9 +63,9 @@ func newPacketBag() *packetBag {
func (d *deFragger) init() {
if d.lru == nil {
d.lru = cache.New(
cache.WithAge[uint16, *packetBag](10),
cache.WithUpdateAgeOnGet[uint16, *packetBag](),
d.lru = lru.New(
lru.WithAge[uint16, *packetBag](10),
lru.WithUpdateAgeOnGet[uint16, *packetBag](),
)
}
}