From e3b69b8ae217cb1c09b1f91902cb3cb77d16c748 Mon Sep 17 00:00:00 2001 From: xishang0128 Date: Fri, 12 Apr 2024 04:58:07 +0800 Subject: [PATCH] chore: Make SubScriptioninfo query also follow Proxy --- adapter/provider/provider.go | 8 ++++---- component/resource/vehicle.go | 8 ++++++++ constant/provider/interface.go | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/adapter/provider/provider.go b/adapter/provider/provider.go index 2715a309..a40a50ec 100644 --- a/adapter/provider/provider.go +++ b/adapter/provider/provider.go @@ -124,8 +124,8 @@ func (pp *proxySetProvider) getSubscriptionInfo() { go func() { ctx, cancel := context.WithTimeout(context.Background(), time.Second*90) defer cancel() - resp, err := mihomoHttp.HttpRequest(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(), - http.MethodGet, http.Header{"User-Agent": {C.UA}}, nil) + resp, err := mihomoHttp.HttpRequestWithProxy(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(), + http.MethodGet, http.Header{"User-Agent": {C.UA}}, nil, pp.Vehicle().Proxy()) if err != nil { return } @@ -133,8 +133,8 @@ func (pp *proxySetProvider) getSubscriptionInfo() { userInfoStr := strings.TrimSpace(resp.Header.Get("subscription-userinfo")) if userInfoStr == "" { - resp2, err := mihomoHttp.HttpRequest(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(), - http.MethodGet, http.Header{"User-Agent": {"Quantumultx"}}, nil) + resp2, err := mihomoHttp.HttpRequestWithProxy(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(), + http.MethodGet, http.Header{"User-Agent": {"Quantumultx"}}, nil, pp.Vehicle().Proxy()) if err != nil { return } diff --git a/component/resource/vehicle.go b/component/resource/vehicle.go index 2d71be94..b13369d2 100644 --- a/component/resource/vehicle.go +++ b/component/resource/vehicle.go @@ -28,6 +28,10 @@ func (f *FileVehicle) Read() ([]byte, error) { return os.ReadFile(f.path) } +func (f *FileVehicle) Proxy() string { + return "" +} + func NewFileVehicle(path string) *FileVehicle { return &FileVehicle{path: path} } @@ -51,6 +55,10 @@ func (h *HTTPVehicle) Path() string { return h.path } +func (h *HTTPVehicle) Proxy() string { + return h.proxy +} + func (h *HTTPVehicle) Read() ([]byte, error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*20) defer cancel() diff --git a/constant/provider/interface.go b/constant/provider/interface.go index f2b6939e..bb73d1bc 100644 --- a/constant/provider/interface.go +++ b/constant/provider/interface.go @@ -31,6 +31,7 @@ func (v VehicleType) String() string { type Vehicle interface { Read() ([]byte, error) Path() string + Proxy() string Type() VehicleType }