1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-22 05:29:14 -04:00

merge ext into core

This commit is contained in:
Darien Raymond
2019-02-10 19:04:11 +01:00
parent d84166ba35
commit 4eb2b5e607
71 changed files with 6346 additions and 18 deletions

View File

@@ -10,9 +10,17 @@ import (
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/common/platform"
"v2ray.com/ext/sysio"
"v2ray.com/core/common/platform/filesystem"
)
func init() {
wd, err := os.Getwd()
common.Must(err)
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat")))
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat")))
}
func TestGeoIPMatcherContainer(t *testing.T) {
container := &router.GeoIPMatcherContainer{}
@@ -112,8 +120,6 @@ func TestGeoIPMatcher(t *testing.T) {
}
func TestGeoIPMatcher4CN(t *testing.T) {
common.Must(sysio.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", "release", "config", "geoip.dat")))
ips, err := loadGeoIP("CN")
common.Must(err)
@@ -126,8 +132,6 @@ func TestGeoIPMatcher4CN(t *testing.T) {
}
func TestGeoIPMatcher6US(t *testing.T) {
common.Must(sysio.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", "release", "config", "geoip.dat")))
ips, err := loadGeoIP("US")
common.Must(err)
@@ -140,7 +144,7 @@ func TestGeoIPMatcher6US(t *testing.T) {
}
func loadGeoIP(country string) ([]*router.CIDR, error) {
geoipBytes, err := sysio.ReadAsset("geoip.dat")
geoipBytes, err := filesystem.ReadAsset("geoip.dat")
if err != nil {
return nil, err
}
@@ -159,8 +163,6 @@ func loadGeoIP(country string) ([]*router.CIDR, error) {
}
func BenchmarkGeoIPMatcher4CN(b *testing.B) {
common.Must(sysio.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", "release", "config", "geoip.dat")))
ips, err := loadGeoIP("CN")
common.Must(err)
@@ -175,8 +177,6 @@ func BenchmarkGeoIPMatcher4CN(b *testing.B) {
}
func BenchmarkGeoIPMatcher6US(b *testing.B) {
common.Must(sysio.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", "release", "config", "geoip.dat")))
ips, err := loadGeoIP("US")
common.Must(err)