From c8d572039ff1bb2c26d58df39d6cf66b803f32ed Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Mon, 13 Jan 2020 17:06:09 +0800 Subject: [PATCH] fix: cycle import --- service/controller/version.go | 3 ++- service/service/GFWList.go | 5 +++-- service/service/import.go | 4 ++-- service/service/latency.go | 3 ++- service/service/subscription.go | 5 +++-- service/tools/{ => httpClient}/httpClient.go | 2 +- service/tools/{ => httpClient}/httpGetUsingCertainClient.go | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) rename service/tools/{ => httpClient}/httpClient.go (99%) rename service/tools/{ => httpClient}/httpGetUsingCertainClient.go (91%) diff --git a/service/controller/version.go b/service/controller/version.go index ebe26426..60ad14ae 100644 --- a/service/controller/version.go +++ b/service/controller/version.go @@ -5,6 +5,7 @@ import ( "V2RayA/model/v2ray" "V2RayA/service" "V2RayA/tools" + "V2RayA/tools/httpClient" "github.com/gin-gonic/gin" ) @@ -27,7 +28,7 @@ func GetVersion(ctx *gin.Context) { } func GetRemoteGFWListVersion(ctx *gin.Context) { - c, err := tools.GetHttpClientAutomatically() + c, err := httpClient.GetHttpClientAutomatically() if err != nil { tools.ResponseError(ctx, err) return diff --git a/service/service/GFWList.go b/service/service/GFWList.go index c495b790..c54114c7 100644 --- a/service/service/GFWList.go +++ b/service/service/GFWList.go @@ -6,6 +6,7 @@ import ( "V2RayA/model/v2ray" "V2RayA/persistence/configure" "V2RayA/tools" + "V2RayA/tools/httpClient" "github.com/PuerkitoBio/goquery" gonanoid "github.com/matoous/go-nanoid" "github.com/pkg/errors" @@ -16,7 +17,7 @@ import ( ) func GetRemoteGFWListUpdateTime(c *http.Client) (t time.Time, err error) { - resp, err := tools.HttpGetUsingSpecificClient(c, "https://github.com/ToutyRater/V2Ray-SiteDAT/contributors/master/geofiles/h2y.dat") + resp, err := httpClient.HttpGetUsingSpecificClient(c, "https://github.com/ToutyRater/V2Ray-SiteDAT/contributors/master/geofiles/h2y.dat") if err != nil { return } @@ -33,7 +34,7 @@ func GetRemoteGFWListUpdateTime(c *http.Client) (t time.Time, err error) { return time.Parse(time.RFC3339, timeRaw) } func IsUpdate() (update bool, remoteTime time.Time, err error) { - c, err := tools.GetHttpClientAutomatically() + c, err := httpClient.GetHttpClientAutomatically() if err != nil { return } diff --git a/service/service/import.go b/service/service/import.go index 283179b6..e1b9f096 100644 --- a/service/service/import.go +++ b/service/service/import.go @@ -5,7 +5,7 @@ import ( "V2RayA/model/touch" "V2RayA/model/v2ray" "V2RayA/persistence/configure" - "V2RayA/tools" + "V2RayA/tools/httpClient" "errors" "fmt" "strings" @@ -46,7 +46,7 @@ func Import(url string, which *configure.Which) (err error) { if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") { url = "http://" + url } - c, err := tools.GetHttpClientAutomatically() + c, err := httpClient.GetHttpClientAutomatically() if err != nil { return errors.New("尝试使用代理失败,建议修改设置为直连模式再试" + err.Error()) } diff --git a/service/service/latency.go b/service/service/latency.go index 28396e65..ad4b0b51 100644 --- a/service/service/latency.go +++ b/service/service/latency.go @@ -7,6 +7,7 @@ import ( "V2RayA/model/vmessInfo" "V2RayA/persistence/configure" "V2RayA/tools" + "V2RayA/tools/httpClient" "errors" "fmt" "net" @@ -189,7 +190,7 @@ func TestHttpLatency(which []configure.Which, timeout time.Duration, maxParallel return which, nil } func httpLatency(which *configure.Which, port string, timeout time.Duration) { - c, err := tools.GetHttpClientWithProxy("socks5://127.0.0.1:" + port) + c, err := httpClient.GetHttpClientWithProxy("socks5://127.0.0.1:" + port) if err != nil { which.Latency = err.Error() return diff --git a/service/service/subscription.go b/service/service/subscription.go index 54926d00..1a533530 100644 --- a/service/service/subscription.go +++ b/service/service/subscription.go @@ -5,6 +5,7 @@ import ( "V2RayA/model/touch" "V2RayA/persistence/configure" "V2RayA/tools" + "V2RayA/tools/httpClient" "bytes" "errors" "log" @@ -18,7 +19,7 @@ func ResolveSubscription(source string) (infos []*nodeData.NodeData, err error) func ResolveSubscriptionWithClient(source string, client *http.Client) (infos []*nodeData.NodeData, err error) { // get请求source - res, err := tools.HttpGetUsingSpecificClient(client, source) + res, err := httpClient.HttpGetUsingSpecificClient(client, source) if err != nil { return } @@ -50,7 +51,7 @@ func ResolveSubscriptionWithClient(source string, client *http.Client) (infos [] func UpdateSubscription(index int, disconnectIfNecessary bool) (err error) { subscriptions := configure.GetSubscriptions() addr := subscriptions[index].Address - c, err := tools.GetHttpClientAutomatically() + c, err := httpClient.GetHttpClientAutomatically() if err != nil { reason := "尝试使用代理失败,建议修改设置为直连模式再试" return errors.New(reason) diff --git a/service/tools/httpClient.go b/service/tools/httpClient/httpClient.go similarity index 99% rename from service/tools/httpClient.go rename to service/tools/httpClient/httpClient.go index c54e8a29..8317ff62 100644 --- a/service/tools/httpClient.go +++ b/service/tools/httpClient/httpClient.go @@ -1,4 +1,4 @@ -package tools +package httpClient import ( "V2RayA/extra/proxyWithHttp" diff --git a/service/tools/httpGetUsingCertainClient.go b/service/tools/httpClient/httpGetUsingCertainClient.go similarity index 91% rename from service/tools/httpGetUsingCertainClient.go rename to service/tools/httpClient/httpGetUsingCertainClient.go index dbd4be0e..eb4e87cc 100644 --- a/service/tools/httpGetUsingCertainClient.go +++ b/service/tools/httpClient/httpGetUsingCertainClient.go @@ -1,4 +1,4 @@ -package tools +package httpClient import "net/http"