client: Use more accurate QUIT message for ping timeouts

This commit is contained in:
Daniel Oaks 2016-06-30 15:35:34 +10:00
parent b820559050
commit 5d3b185881
1 changed files with 8 additions and 3 deletions

View File

@ -8,16 +8,21 @@ package irc
import ( import (
"fmt" "fmt"
"net" "net"
"strconv"
"time" "time"
"github.com/DanielOaks/girc-go/ircmsg" "github.com/DanielOaks/girc-go/ircmsg"
) )
const ( const (
IDLE_TIMEOUT = time.Minute // how long before a client is considered idle IDLE_TIMEOUT = time.Minute + time.Second*30 // how long before a client is considered idle
QUIT_TIMEOUT = time.Minute // how long after idle before a client is kicked QUIT_TIMEOUT = time.Minute // how long after idle before a client is kicked
) )
var (
TIMEOUT_STATED_SECONDS = strconv.Itoa(int((IDLE_TIMEOUT + QUIT_TIMEOUT).Seconds()))
)
type Client struct { type Client struct {
atime time.Time atime time.Time
authorized bool authorized bool
@ -117,7 +122,7 @@ func (client *Client) run() {
// //
func (client *Client) connectionTimeout() { func (client *Client) connectionTimeout() {
client.Quit("connection timeout") client.Quit(fmt.Sprintf("Ping timeout: %s seconds", TIMEOUT_STATED_SECONDS))
client.isQuitting = true client.isQuitting = true
} }