mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
cleanup
This commit is contained in:
parent
2dc69c7e3d
commit
3b12dec207
@ -60,19 +60,9 @@ func NewClient(server *Server, conn net.Conn) *Client {
|
||||
// command goroutine
|
||||
//
|
||||
|
||||
func (client *Client) send(command Command) {
|
||||
command.SetClient(client)
|
||||
client.server.commands <- command
|
||||
}
|
||||
|
||||
func (client *Client) run() {
|
||||
client.send(&ProxyCommand{
|
||||
hostname: AddrLookupHostname(client.socket.conn.RemoteAddr()),
|
||||
})
|
||||
|
||||
for command := range client.commands {
|
||||
checkPass, ok := command.(checkPasswordCommand)
|
||||
if ok {
|
||||
if checkPass, ok := command.(checkPasswordCommand); ok {
|
||||
checkPass.LoadPassword(client.server)
|
||||
// Block the client thread while handling a potentially expensive
|
||||
// password bcrypt operation. Since the server is single-threaded
|
||||
@ -81,13 +71,9 @@ func (client *Client) run() {
|
||||
// completes. This could be a form of DoS if handled naively.
|
||||
checkPass.CheckPassword()
|
||||
}
|
||||
|
||||
client.send(command)
|
||||
command.SetClient(client)
|
||||
client.server.commands <- command
|
||||
}
|
||||
|
||||
client.send(&QuitCommand{
|
||||
message: "connection closed",
|
||||
})
|
||||
}
|
||||
|
||||
func (client *Client) connectionTimeout() {
|
||||
|
@ -38,6 +38,10 @@ func (socket *Socket) Close() {
|
||||
}
|
||||
|
||||
func (socket *Socket) readLines(commands chan<- Command) {
|
||||
commands <- &ProxyCommand{
|
||||
hostname: AddrLookupHostname(socket.conn.RemoteAddr()),
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(socket.conn)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
@ -58,6 +62,10 @@ func (socket *Socket) readLines(commands chan<- Command) {
|
||||
Log.debug.Printf("%s error: %s", socket, err)
|
||||
}
|
||||
|
||||
commands <- &QuitCommand{
|
||||
message: "connection closed",
|
||||
}
|
||||
|
||||
close(commands)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user