mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
commit
82009c869e
@ -120,12 +120,9 @@ Start:
|
|||||||
|
|
||||||
if len(s.config.Accounts) > 0 {
|
if len(s.config.Accounts) > 0 {
|
||||||
user, pass, ok := parseBasicAuth(request.Header.Get("Proxy-Authorization"))
|
user, pass, ok := parseBasicAuth(request.Header.Get("Proxy-Authorization"))
|
||||||
if !ok {
|
if !ok || !s.config.HasAccount(user, pass) {
|
||||||
_, err := conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n\r\n"))
|
_, err := conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n" +
|
||||||
return err
|
"Proxy-Authenticate: Basic realm=\"V2Ray\"\r\n\r\n"))
|
||||||
}
|
|
||||||
if !s.config.HasAccount(user, pass) {
|
|
||||||
_, err := conn.Write([]byte("HTTP/1.1 401 UNAUTHORIZED\r\n\r\n"))
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ func TestHttpBasicAuth(t *testing.T) {
|
|||||||
setProxyBasicAuth(req, "a", "c")
|
setProxyBasicAuth(req, "a", "c")
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
assert(err, IsNil)
|
assert(err, IsNil)
|
||||||
assert(resp.StatusCode, Equals, 401)
|
assert(resp.StatusCode, Equals, 407)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user