Compare commits

...

2 Commits

Author SHA1 Message Date
ForestL
4437c8861c
chore: better getUpdateTime() for iterating all Geofiles (#1570) 2024-10-11 08:46:31 +08:00
xishang0128
57725078e0 chore: Adjust the error log for the search process 2024-10-11 07:35:51 +08:00
2 changed files with 15 additions and 13 deletions

View File

@ -229,20 +229,22 @@ func UpdateGeoDatabases() error {
}
func getUpdateTime() (err error, time time.Time) {
var fileInfo os.FileInfo
if geodata.GeodataMode() {
fileInfo, err = os.Stat(C.Path.GeoIP())
if err != nil {
return err, time
}
} else {
fileInfo, err = os.Stat(C.Path.MMDB())
if err != nil {
return err, time
filesToCheck := []string{
C.Path.GeoIP(),
C.Path.MMDB(),
C.Path.ASN(),
C.Path.GeoSite(),
}
for _, file := range filesToCheck {
var fileInfo os.FileInfo
fileInfo, err = os.Stat(file)
if err == nil {
return nil, fileInfo.ModTime()
}
}
return nil, fileInfo.ModTime()
return
}
func RegisterGeoUpdater() {

View File

@ -625,7 +625,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
// normal check for process
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort))
if err != nil {
log.Debugln("[Process] find process %s error: %v", metadata.String(), err)
log.Debugln("[Process] find process error for %s: %v", metadata.String(), err)
} else {
metadata.Process = filepath.Base(path)
metadata.ProcessPath = path
@ -639,7 +639,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
// check package names
pkg, err := P.FindPackageName(metadata)
if err != nil {
log.Debugln("[Process] find process %s error: %v", metadata.String(), err)
log.Debugln("[Process] find process error for %s: %v", metadata.String(), err)
} else {
metadata.Process = pkg
}