mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 03:47:38 +03:00
Add headers option to http connect client
This commit is contained in:
parent
6d63c1a7dc
commit
121c0b14e4
1 changed files with 9 additions and 1 deletions
|
@ -23,14 +23,16 @@ type Client struct {
|
|||
serverAddr M.Socksaddr
|
||||
username string
|
||||
password string
|
||||
headers http.Header
|
||||
}
|
||||
|
||||
func NewClient(dialer N.Dialer, serverAddr M.Socksaddr, username string, password string) *Client {
|
||||
func NewClient(dialer N.Dialer, serverAddr M.Socksaddr, username string, password string, headers http.Header) *Client {
|
||||
return &Client{
|
||||
dialer,
|
||||
serverAddr,
|
||||
username,
|
||||
password,
|
||||
headers,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +61,12 @@ func (c *Client) DialContext(ctx context.Context, network string, destination M.
|
|||
"Proxy-Connection": []string{"Keep-Alive"},
|
||||
},
|
||||
}
|
||||
for key, valueList := range c.headers {
|
||||
request.Header.Set(key, valueList[0])
|
||||
for _, value := range valueList[1:] {
|
||||
request.Header.Add(key, value)
|
||||
}
|
||||
}
|
||||
if c.username != "" {
|
||||
auth := c.username + ":" + c.password
|
||||
request.Header.Add("Proxy-Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(auth)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue