update config
This commit is contained in:
@ -23,6 +23,7 @@ func init() {
|
||||
}
|
||||
|
||||
type httpConnector struct {
|
||||
user *url.Userinfo
|
||||
md metadata
|
||||
logger logger.Logger
|
||||
}
|
||||
@ -34,6 +35,7 @@ func NewConnector(opts ...connector.Option) connector.Connector {
|
||||
}
|
||||
|
||||
return &httpConnector{
|
||||
user: options.User,
|
||||
logger: options.Logger,
|
||||
}
|
||||
}
|
||||
@ -65,7 +67,7 @@ func (c *httpConnector) Connect(ctx context.Context, conn net.Conn, network, add
|
||||
}
|
||||
req.Header.Set("Proxy-Connection", "keep-alive")
|
||||
|
||||
if user := c.md.User; user != nil {
|
||||
if user := c.user; user != nil {
|
||||
u := user.Username()
|
||||
p, _ := user.Password()
|
||||
req.Header.Set("Proxy-Authorization",
|
||||
|
@ -2,8 +2,6 @@ package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/gost/pkg/metadata"
|
||||
@ -11,7 +9,6 @@ import (
|
||||
|
||||
type metadata struct {
|
||||
connectTimeout time.Duration
|
||||
User *url.Userinfo
|
||||
header http.Header
|
||||
}
|
||||
|
||||
@ -24,15 +21,6 @@ func (c *httpConnector) parseMetadata(md mdata.Metadata) (err error) {
|
||||
|
||||
c.md.connectTimeout = mdata.GetDuration(md, connectTimeout)
|
||||
|
||||
if v := mdata.GetString(md, user); v != "" {
|
||||
ss := strings.SplitN(v, ":", 2)
|
||||
if len(ss) == 1 {
|
||||
c.md.User = url.User(ss[0])
|
||||
} else {
|
||||
c.md.User = url.UserPassword(ss[0], ss[1])
|
||||
}
|
||||
}
|
||||
|
||||
if mm := mdata.GetStringMapString(md, header); len(mm) > 0 {
|
||||
hd := http.Header{}
|
||||
for k, v := range mm {
|
||||
|
Reference in New Issue
Block a user