mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-05-31 12:49:22 +00:00
Add headers option for HTTP outbound
This commit is contained in:
parent
b491c350ae
commit
0a4abcbbc8
4 changed files with 35 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ package outbound
|
|||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
|
|
@ -29,6 +30,13 @@ func NewHTTP(router adapter.Router, logger log.ContextLogger, tag string, option
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var headers http.Header
|
||||
if options.Headers != nil {
|
||||
headers = make(http.Header)
|
||||
for key, values := range options.Headers {
|
||||
headers[key] = values
|
||||
}
|
||||
}
|
||||
return &HTTP{
|
||||
myOutboundAdapter{
|
||||
protocol: C.TypeHTTP,
|
||||
|
|
@ -42,6 +50,8 @@ func NewHTTP(router adapter.Router, logger log.ContextLogger, tag string, option
|
|||
Server: options.ServerOptions.Build(),
|
||||
Username: options.Username,
|
||||
Password: options.Password,
|
||||
Path: options.Path,
|
||||
Headers: headers,
|
||||
}),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue