1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-11 10:20:42 +00:00

完善HTTP基本认证

This commit is contained in:
sunshineplan 2017-12-02 17:07:42 +08:00 committed by GitHub
parent d1fa98b60b
commit cf0fc6e4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,14 +118,11 @@ Start:
return trace
}
if len(s.config.Accounts) > 0 {
if len(s.config.Accounts) > 0 {
user, pass, ok := parseBasicAuth(request.Header.Get("Proxy-Authorization"))
if !ok {
_, err := conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n\r\n"))
return err
}
if !s.config.HasAccount(user, pass) {
_, err := conn.Write([]byte("HTTP/1.1 401 UNAUTHORIZED\r\n\r\n"))
if !ok || !s.config.HasAccount(user, pass) {
_, err := conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n" +
"Proxy-Authenticate: Basic realm=\"V2Ray\"\r\n\r\n"))
return err
}
}