mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-11-14 17:12:55 +00:00
remove duplicated methods
This commit is contained in:
parent
5e7e549ec1
commit
b9fb670ca6
@ -104,7 +104,7 @@ func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Base(err).Message("Socks|Server: Failed to read username or password.")
|
return nil, errors.Base(err).Message("Socks|Server: Failed to read username or password.")
|
||||||
}
|
}
|
||||||
if !s.validate(username, password) {
|
if !s.config.HasAccount(username, password) {
|
||||||
writeSocks5AuthenticationResponse(writer, 0xFF)
|
writeSocks5AuthenticationResponse(writer, 0xFF)
|
||||||
return nil, errors.Base(err).Message("Socks|Server: Invalid username or password.")
|
return nil, errors.Base(err).Message("Socks|Server: Invalid username or password.")
|
||||||
}
|
}
|
||||||
@ -186,11 +186,6 @@ func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol
|
|||||||
return nil, errors.New("Socks|Server: Unknown Socks version: ", version)
|
return nil, errors.New("Socks|Server: Unknown Socks version: ", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServerSession) validate(username, password string) bool {
|
|
||||||
p, found := s.config.Accounts[username]
|
|
||||||
return found && p == password
|
|
||||||
}
|
|
||||||
|
|
||||||
func readUsernamePassword(reader io.Reader) (string, string, error) {
|
func readUsernamePassword(reader io.Reader) (string, string, error) {
|
||||||
buffer := buf.NewLocal(512)
|
buffer := buf.NewLocal(512)
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user