This commit is contained in:
Clash-Mini
2022-02-06 01:59:35 +08:00
parent 28a1475f66
commit 4a446c4e31
6 changed files with 56 additions and 21 deletions

View File

@ -1,13 +1,20 @@
package constant
import (
"io/ioutil"
"os"
P "path"
"path/filepath"
"strings"
)
const Name = "clash"
var (
GeositeName = "GeoSite.dat"
GeoipName = "GeoIP.dat"
)
// Path is used to get the configuration path
var Path = func() *path {
homeDir, err := os.UserHomeDir()
@ -65,10 +72,40 @@ func (p *path) Cache() string {
}
func (p *path) GeoIP() string {
files, err := ioutil.ReadDir(p.homeDir)
if err != nil {
return ""
}
for _, fi := range files {
if fi.IsDir() {
// 目录则直接跳过
continue
} else {
if strings.EqualFold(fi.Name(), "GeoIP.dat") {
GeoipName = fi.Name()
return P.Join(p.homeDir, fi.Name())
}
}
}
return P.Join(p.homeDir, "GeoIP.dat")
}
func (p *path) GeoSite() string {
files, err := ioutil.ReadDir(p.homeDir)
if err != nil {
return ""
}
for _, fi := range files {
if fi.IsDir() {
// 目录则直接跳过
continue
} else {
if strings.EqualFold(fi.Name(), "GeoSite.dat") {
GeositeName = fi.Name()
return P.Join(p.homeDir, fi.Name())
}
}
}
return P.Join(p.homeDir, "GeoSite.dat")
}

View File

@ -1,9 +1,8 @@
package constant
var (
Meta = true
Version = "1.9.0"
BuildTime = "unknown time"
AutoIptables string
ClashName = "Clash.Meta"
Meta = true
Version = "1.9.1"
BuildTime = "unknown time"
ClashName = "Clash.Meta"
)