mirror of https://github.com/fluffle/goirc
Allow non-context Dialers
Dialers who don't implement DialContext but upgrade past https://github.com/fluffle/goirc/pull/109 (which is 2.5 years old but still) will break. This change falls back to the non-context dial method, where calls may take longer and time out, and goirc would give them a warning as well.
This commit is contained in:
parent
8b460bc60f
commit
ceced391f3
|
@ -413,15 +413,24 @@ func (conn *Conn) internalConnect(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
contextProxyDialer, ok := proxyDialer.(proxy.ContextDialer)
|
contextProxyDialer, ok := proxyDialer.(proxy.ContextDialer)
|
||||||
if !ok {
|
if ok {
|
||||||
return errors.New("Dialer for proxy does not support context")
|
conn.proxyDialer = contextProxyDialer
|
||||||
}
|
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
||||||
conn.proxyDialer = contextProxyDialer
|
if s, err := conn.proxyDialer.DialContext(ctx, "tcp", conn.cfg.Server); err == nil {
|
||||||
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
conn.sock = s
|
||||||
if s, err := conn.proxyDialer.DialContext(ctx, "tcp", conn.cfg.Server); err == nil {
|
} else {
|
||||||
conn.sock = s
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return err
|
logging.Warn("Dialer for proxy does not support context, please implement DialContext")
|
||||||
|
|
||||||
|
conn.proxyDialer = proxyDialer
|
||||||
|
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
||||||
|
if s, err := conn.proxyDialer.Dial("tcp", conn.cfg.Server); err == nil {
|
||||||
|
conn.sock = s
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
||||||
|
|
Loading…
Reference in New Issue