Skip to content

Commit

Permalink
feat(distribution): reset cache before starting
Browse files Browse the repository at this point in the history
  • Loading branch information
igoogolx committed Oct 19, 2023
1 parent 65b3a47 commit db9cf3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/cfg/distribution/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
var dnsDomainCache, _ = lru.New(4 * 1024)
var dnsRuleCache, _ = lru.New(4 * 1024)

func ResetCache() {
dnsDomainCache.Purge()
dnsRuleCache.Purge()
}

func GetCachedDnsItem(ip string) (string, constants.DnsType, bool) {
rawCachedDomain, ok := dnsDomainCache.Get(ip)
if !ok {
Expand Down
1 change: 1 addition & 0 deletions internal/cfg/distribution/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func New(
tunInterfaceName string,
defaultInterfaceName string,
) (Config, error) {
ResetCache()
rEngine, err := ruleEngine.New(ruleId, rules)
if err != nil {
return Config{}, err
Expand Down

0 comments on commit db9cf3b

Please sign in to comment.