mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-22 20:40:12 +00:00
Disable HTTP auth when no username/password is set
This commit is contained in:
parent
36cf8e6013
commit
d3ad171761
@ -147,6 +147,12 @@ func proxyClient(args []string) {
|
|||||||
|
|
||||||
if len(config.HTTPAddr) > 0 {
|
if len(config.HTTPAddr) > 0 {
|
||||||
go func() {
|
go func() {
|
||||||
|
var authFunc func(user, password string) bool
|
||||||
|
if config.HTTPUser != "" && config.HTTPPassword != "" {
|
||||||
|
authFunc = func(user, password string) bool {
|
||||||
|
return config.HTTPUser == user && config.HTTPPassword == password
|
||||||
|
}
|
||||||
|
}
|
||||||
proxy, err := hyHTTP.NewProxyHTTPServer(client, time.Duration(config.HTTPTimeout)*time.Second, aclEngine,
|
proxy, err := hyHTTP.NewProxyHTTPServer(client, time.Duration(config.HTTPTimeout)*time.Second, aclEngine,
|
||||||
func(reqAddr string, action acl.Action, arg string) {
|
func(reqAddr string, action acl.Action, arg string) {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
@ -154,12 +160,7 @@ func proxyClient(args []string) {
|
|||||||
"dst": reqAddr,
|
"dst": reqAddr,
|
||||||
}).Debug("New HTTP request")
|
}).Debug("New HTTP request")
|
||||||
},
|
},
|
||||||
func(user, password string) bool {
|
authFunc)
|
||||||
if config.HTTPUser == "" || config.HTTPPassword == "" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return config.HTTPUser == user && config.HTTPPassword == password
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithField("error", err).Fatal("HTTP server initialization failed")
|
logrus.WithField("error", err).Fatal("HTTP server initialization failed")
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,9 @@ func NewProxyHTTPServer(hyClient core.Client, idleTimeout time.Duration, aclEngi
|
|||||||
//TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
|
//TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
|
||||||
}
|
}
|
||||||
proxy.ConnectDial = nil
|
proxy.ConnectDial = nil
|
||||||
auth.ProxyBasic(proxy, "hysteria client", basicAuthFunc)
|
if basicAuthFunc != nil {
|
||||||
|
auth.ProxyBasic(proxy, "hysteria client", basicAuthFunc)
|
||||||
|
}
|
||||||
return proxy, nil
|
return proxy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user