Moved timeout to Client from Connect

This commit is contained in:
kyle 2014-12-20 20:39:44 +02:00
parent dde47a6a32
commit 5e5f5f0253
1 changed files with 1 additions and 1 deletions

View File

@ -128,6 +128,7 @@ func Client(cfg *Config) *Conn {
} }
dialer := new(net.Dialer) dialer := new(net.Dialer)
dialer.Timeout = cfg.Timeout
if cfg.LocalAddr != "" { if cfg.LocalAddr != "" {
if !hasPort(cfg.LocalAddr) { if !hasPort(cfg.LocalAddr) {
cfg.LocalAddr += ":0" cfg.LocalAddr += ":0"
@ -227,7 +228,6 @@ func (conn *Conn) Connect() error {
if conn.connected { if conn.connected {
return fmt.Errorf("irc.Connect(): Cannot connect to %s, already connected.", conn.cfg.Server) return fmt.Errorf("irc.Connect(): Cannot connect to %s, already connected.", conn.cfg.Server)
} }
conn.dialer.Timeout = conn.cfg.Timeout
if conn.cfg.SSL { if conn.cfg.SSL {
if !hasPort(conn.cfg.Server) { if !hasPort(conn.cfg.Server) {
conn.cfg.Server = net.JoinHostPort(conn.cfg.Server, "6697") conn.cfg.Server = net.JoinHostPort(conn.cfg.Server, "6697")