mirror of https://github.com/dnomd343/XProxy.git
dnomd343
2 years ago
6 changed files with 58 additions and 65 deletions
@ -0,0 +1,21 @@ |
|||
package asset |
|||
|
|||
import ( |
|||
"XProxy/cmd/common" |
|||
log "github.com/sirupsen/logrus" |
|||
) |
|||
|
|||
func extractFile(archive string, geoFile string, targetDir string) { |
|||
if common.IsFileExist(targetDir + "/" + geoFile) { |
|||
log.Debugf("Asset %s exist -> skip extract", geoFile) |
|||
return |
|||
} |
|||
log.Infof("Extract asset file -> %s", targetDir+"/"+geoFile) |
|||
common.RunCommand("tar", "xvf", archive, "./"+geoFile, "-C", targetDir) |
|||
} |
|||
|
|||
func Load(assetFile string, assetDir string) { |
|||
common.CreateFolder(assetDir) |
|||
extractFile(assetFile, "geoip.dat", assetDir) |
|||
extractFile(assetFile, "geosite.dat", assetDir) |
|||
} |
@ -1,25 +0,0 @@ |
|||
package asset |
|||
|
|||
import ( |
|||
"XProxy/cmd/common" |
|||
log "github.com/sirupsen/logrus" |
|||
) |
|||
|
|||
func extractGeoFile(archivePath string, geoFile string, targetDir string) { |
|||
if common.IsFileExist(targetDir + "/" + geoFile) { |
|||
log.Debugf("Asset %s exist -> skip extract", geoFile) |
|||
return |
|||
} |
|||
log.Infof("Extract asset file -> %s", targetDir+"/"+geoFile) |
|||
common.RunCommand("tar", "xvf", archivePath, "./"+geoFile, "-C", targetDir) |
|||
} |
|||
|
|||
func LoadGeoIp(assetFile string, assetDir string) { |
|||
common.CreateFolder(assetDir) |
|||
extractGeoFile(assetFile, "geoip.dat", assetDir) |
|||
} |
|||
|
|||
func LoadGeoSite(assetFile string, assetDir string) { |
|||
common.CreateFolder(assetDir) |
|||
extractGeoFile(assetFile, "geosite.dat", assetDir) |
|||
} |
Loading…
Reference in new issue