update config

This commit is contained in:
ginuerzh
2022-01-03 23:45:49 +08:00
parent 14537d16ea
commit 566e930010
42 changed files with 412 additions and 521 deletions

View File

@ -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",

View File

@ -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 {