mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
feature proxy rewrite.
This commit is contained in:
parent
439c3422fb
commit
143d5ef8ab
@ -152,6 +152,7 @@ type JsonConfig struct {
|
||||
} `json:"_rate_limit"`
|
||||
IgnoreInvalidCQCode bool `json:"ignore_invalid_cqcode"`
|
||||
ForceFragmented bool `json:"force_fragmented"`
|
||||
ProxyRewrite string `json:"proxy_rewrite"`
|
||||
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
|
||||
HttpConfig *GoCQHttpConfig `json:"http_config"`
|
||||
WSConfig *GoCQWebsocketConfig `json:"ws_config"`
|
||||
|
@ -5,7 +5,9 @@ import (
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -14,7 +16,27 @@ import (
|
||||
|
||||
var client = &http.Client{
|
||||
Timeout: time.Second * 15,
|
||||
Transport: &http.Transport{
|
||||
Proxy: func(request *http.Request) (u *url.URL, e error) {
|
||||
if Proxy == "" {
|
||||
return http.ProxyFromEnvironment(request)
|
||||
}
|
||||
return url.Parse(Proxy)
|
||||
},
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
DualStack: true,
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
},
|
||||
}
|
||||
|
||||
var Proxy string
|
||||
|
||||
func GetBytes(url string) ([]byte, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user