feat: support users to customize download ua
This commit is contained in:
parent
cb5ab95eaa
commit
a1daf6ae35
3 changed files with 12 additions and 4 deletions
|
@ -10,14 +10,12 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/component/tls"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/listener/inner"
|
||||
)
|
||||
|
||||
const (
|
||||
UA = "clash.meta"
|
||||
)
|
||||
|
||||
func HttpRequest(ctx context.Context, url, method string, header map[string][]string, body io.Reader) (*http.Response, error) {
|
||||
UA := C.UA
|
||||
method = strings.ToUpper(method)
|
||||
urlRes, err := URL.Parse(url)
|
||||
if err != nil {
|
||||
|
|
|
@ -60,6 +60,7 @@ type General struct {
|
|||
Sniffing bool `json:"sniffing"`
|
||||
EBpf EBpf `json:"-"`
|
||||
GlobalClientFingerprint string `json:"global-client-fingerprint"`
|
||||
GlobalUA string `json:"global-ua"`
|
||||
KeepAliveInterval int `json:"keep-alive-interval"`
|
||||
}
|
||||
|
||||
|
@ -284,6 +285,7 @@ type RawConfig struct {
|
|||
TCPConcurrent bool `yaml:"tcp-concurrent" json:"tcp-concurrent"`
|
||||
FindProcessMode P.FindProcessMode `yaml:"find-process-mode" json:"find-process-mode"`
|
||||
GlobalClientFingerprint string `yaml:"global-client-fingerprint"`
|
||||
GlobalUA string `yaml:"global-ua"`
|
||||
KeepAliveInterval int `yaml:"keep-alive-interval"`
|
||||
|
||||
Sniffer RawSniffer `yaml:"sniffer"`
|
||||
|
@ -370,6 +372,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
|||
ProxyGroup: []map[string]any{},
|
||||
TCPConcurrent: false,
|
||||
FindProcessMode: P.FindProcessStrict,
|
||||
GlobalUA: "clash.meta",
|
||||
Tun: RawTun{
|
||||
Enable: false,
|
||||
Device: "",
|
||||
|
@ -571,6 +574,7 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
|||
C.GeoSiteUrl = cfg.GeoXUrl.GeoSite
|
||||
C.MmdbUrl = cfg.GeoXUrl.Mmdb
|
||||
C.GeodataMode = cfg.GeodataMode
|
||||
C.UA = cfg.GlobalUA
|
||||
if cfg.KeepAliveInterval != 0 {
|
||||
N.KeepAliveInterval = time.Duration(cfg.KeepAliveInterval) * time.Second
|
||||
}
|
||||
|
@ -617,6 +621,7 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
|||
FindProcessMode: cfg.FindProcessMode,
|
||||
EBpf: cfg.EBpf,
|
||||
GlobalClientFingerprint: cfg.GlobalClientFingerprint,
|
||||
GlobalUA: cfg.GlobalUA,
|
||||
KeepAliveInterval: cfg.KeepAliveInterval,
|
||||
}, nil
|
||||
}
|
||||
|
|
5
constant/http.go
Normal file
5
constant/http.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
package constant
|
||||
|
||||
var (
|
||||
UA string
|
||||
)
|
Loading…
Reference in a new issue