|
@@ -60,19 +60,9 @@ func NewClient(server *Server, conn net.Conn) *Client {
|
60
|
60
|
// command goroutine
|
61
|
61
|
//
|
62
|
62
|
|
63
|
|
-func (client *Client) send(command Command) {
|
64
|
|
- command.SetClient(client)
|
65
|
|
- client.server.commands <- command
|
66
|
|
-}
|
67
|
|
-
|
68
|
63
|
func (client *Client) run() {
|
69
|
|
- client.send(&ProxyCommand{
|
70
|
|
- hostname: AddrLookupHostname(client.socket.conn.RemoteAddr()),
|
71
|
|
- })
|
72
|
|
-
|
73
|
64
|
for command := range client.commands {
|
74
|
|
- checkPass, ok := command.(checkPasswordCommand)
|
75
|
|
- if ok {
|
|
65
|
+ if checkPass, ok := command.(checkPasswordCommand); ok {
|
76
|
66
|
checkPass.LoadPassword(client.server)
|
77
|
67
|
// Block the client thread while handling a potentially expensive
|
78
|
68
|
// password bcrypt operation. Since the server is single-threaded
|
|
@@ -81,13 +71,9 @@ func (client *Client) run() {
|
81
|
71
|
// completes. This could be a form of DoS if handled naively.
|
82
|
72
|
checkPass.CheckPassword()
|
83
|
73
|
}
|
84
|
|
-
|
85
|
|
- client.send(command)
|
|
74
|
+ command.SetClient(client)
|
|
75
|
+ client.server.commands <- command
|
86
|
76
|
}
|
87
|
|
-
|
88
|
|
- client.send(&QuitCommand{
|
89
|
|
- message: "connection closed",
|
90
|
|
- })
|
91
|
77
|
}
|
92
|
78
|
|
93
|
79
|
func (client *Client) connectionTimeout() {
|