From 82c8e02d021f7cda27ad3fcfc9b3396efc27b622 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Sun, 26 Dec 2021 22:26:53 +0800 Subject: [PATCH] [Style] Add User-Agent for provider request --- adapter/provider/vehicle.go | 3 +++ common/net/http.go | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 common/net/http.go diff --git a/adapter/provider/vehicle.go b/adapter/provider/vehicle.go index 4f08c317..a0237a92 100644 --- a/adapter/provider/vehicle.go +++ b/adapter/provider/vehicle.go @@ -9,6 +9,7 @@ import ( "os" "time" + netHttp "github.com/Dreamacro/clash/common/net" "github.com/Dreamacro/clash/component/dialer" types "github.com/Dreamacro/clash/constant/provider" ) @@ -56,6 +57,8 @@ func (h *HTTPVehicle) Read() ([]byte, error) { } req, err := http.NewRequest(http.MethodGet, uri.String(), nil) + req.Header.Set("user-agent", netHttp.UA) + if err != nil { return nil, err } diff --git a/common/net/http.go b/common/net/http.go new file mode 100644 index 00000000..ae10f7fc --- /dev/null +++ b/common/net/http.go @@ -0,0 +1,5 @@ +package net + +const ( + UA = "Clash" +)