fix HTTP2 auth bug #122
This commit is contained in:
parent
012932fab1
commit
55622a5f43
@ -79,7 +79,13 @@ func initChain() (*gost.Chain, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users, err := parseUsers(node.Values.Get("secrets"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if node.User == nil && len(users) > 0 {
|
||||
node.User = users[0]
|
||||
}
|
||||
serverName, _, _ := net.SplitHostPort(node.Addr)
|
||||
if serverName == "" {
|
||||
serverName = "localhost" // default server name
|
||||
|
@ -1,6 +1,8 @@
|
||||
# username password
|
||||
|
||||
test\admin 123456
|
||||
$test 123456
|
||||
$test.admin$ $123456$
|
||||
@test.admin@ @123456@
|
||||
test.admin# #123456#
|
||||
test.admin\admin 123456
|
||||
test001 123456
|
||||
test002 12345678
|
8
http.go
8
http.go
@ -36,12 +36,10 @@ func (c *httpConnector) Connect(conn net.Conn, addr string) (net.Conn, error) {
|
||||
req.Header.Set("Proxy-Connection", "keep-alive")
|
||||
|
||||
if c.User != nil {
|
||||
s := c.User.String()
|
||||
if _, set := c.User.Password(); !set {
|
||||
s += ":"
|
||||
}
|
||||
u := c.User.Username()
|
||||
p, _ := c.User.Password()
|
||||
req.Header.Set("Proxy-Authorization",
|
||||
"Basic "+base64.StdEncoding.EncodeToString([]byte(s)))
|
||||
"Basic "+base64.StdEncoding.EncodeToString([]byte(u+":"+p)))
|
||||
}
|
||||
|
||||
if err := req.Write(conn); err != nil {
|
||||
|
4
http2.go
4
http2.go
@ -48,8 +48,10 @@ func (c *http2Connector) Connect(conn net.Conn, addr string) (net.Conn, error) {
|
||||
}
|
||||
req.Header.Set("Gost-Target", addr)
|
||||
if c.User != nil {
|
||||
u := c.User.Username()
|
||||
p, _ := c.User.Password()
|
||||
req.Header.Set("Proxy-Authorization",
|
||||
"Basic "+base64.StdEncoding.EncodeToString([]byte(c.User.String())))
|
||||
"Basic "+base64.StdEncoding.EncodeToString([]byte(u+":"+p)))
|
||||
}
|
||||
if Debug {
|
||||
dump, _ := httputil.DumpRequest(req, false)
|
||||
|
Loading…
Reference in New Issue
Block a user