Improve network reset

This commit is contained in:
世界
2026-07-19 17:50:02 +08:00
parent 552994b6ca
commit d2e030bdca
26 changed files with 256 additions and 68 deletions
+1
View File
@@ -14,6 +14,7 @@ import (
type Searcher interface {
FindProcessInfo(ctx context.Context, network string, source netip.AddrPort, destination netip.AddrPort) (*adapter.ConnectionOwner, error)
ResetCache()
Close() error
}
+3
View File
@@ -23,6 +23,9 @@ func NewSearcher(config Config) (Searcher, error) {
return &androidSearcher{config.PackageManager}, nil
}
func (s *androidSearcher) ResetCache() {
}
func (s *androidSearcher) Close() error {
return nil
}
+4
View File
@@ -20,6 +20,10 @@ func NewSearcher(_ Config) (Searcher, error) {
return &darwinSearcher{}, nil
}
func (d *darwinSearcher) ResetCache() {
sharedDarwinConnectionFinder.resetCache()
}
func (d *darwinSearcher) Close() error {
return nil
}
+6
View File
@@ -119,6 +119,12 @@ func (f *darwinConnectionFinder) find(network string, source netip.AddrPort, des
return nil, ErrNotFound
}
func (f *darwinConnectionFinder) resetCache() {
f.access.Lock()
defer f.access.Unlock()
clear(f.snapshots)
}
func (f *darwinConnectionFinder) loadSnapshot(network string, forceRefresh bool) (darwinSnapshot, bool, error) {
f.access.Lock()
defer f.access.Unlock()
+4
View File
@@ -35,6 +35,10 @@ func NewSearcher(config Config) (Searcher, error) {
return searcher, nil
}
func (s *linuxSearcher) ResetCache() {
s.processPathCache.cache.Purge()
}
func (s *linuxSearcher) Close() error {
var errs []error
for _, conn := range s.diagConns {
+3
View File
@@ -28,6 +28,9 @@ func initWin32API() error {
return winiphlpapi.LoadExtendedTable()
}
func (s *windowsSearcher) ResetCache() {
}
func (s *windowsSearcher) Close() error {
return nil
}