mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-01 06:55:25 -05:00
basic auth in http server
This commit is contained in:
@@ -83,6 +83,15 @@ Start:
|
||||
}
|
||||
return trace
|
||||
}
|
||||
|
||||
if len(s.config.Accounts) > 0 {
|
||||
user, pass, ok := request.BasicAuth()
|
||||
if !ok || !s.config.HasAccount(user, pass) {
|
||||
_, err := conn.Write([]byte("HTTP/1.1 401 UNAUTHORIZED\r\n\r\n"))
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Trace(newError("request to Method [", request.Method, "] Host [", request.Host, "] with URL [", request.URL, "]"))
|
||||
conn.SetReadDeadline(time.Time{})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user