mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-21 19:59:51 +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 {
|
||||
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,
|
||||
func(reqAddr string, action acl.Action, arg string) {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
@ -154,12 +160,7 @@ func proxyClient(args []string) {
|
||||
"dst": reqAddr,
|
||||
}).Debug("New HTTP request")
|
||||
},
|
||||
func(user, password string) bool {
|
||||
if config.HTTPUser == "" || config.HTTPPassword == "" {
|
||||
return true
|
||||
}
|
||||
return config.HTTPUser == user && config.HTTPPassword == password
|
||||
})
|
||||
authFunc)
|
||||
if err != nil {
|
||||
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),
|
||||
}
|
||||
proxy.ConnectDial = nil
|
||||
auth.ProxyBasic(proxy, "hysteria client", basicAuthFunc)
|
||||
if basicAuthFunc != nil {
|
||||
auth.ProxyBasic(proxy, "hysteria client", basicAuthFunc)
|
||||
}
|
||||
return proxy, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user