[build]
This commit is contained in:
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
)
|
||||
|
Reference in New Issue
Block a user