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,9 +413,7 @@ func (conn *Conn) internalConnect(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
contextProxyDialer, ok := proxyDialer.(proxy.ContextDialer)
|
||||
if !ok {
|
||||
return errors.New("Dialer for proxy does not support context")
|
||||
}
|
||||
if ok {
|
||||
conn.proxyDialer = contextProxyDialer
|
||||
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
||||
if s, err := conn.proxyDialer.DialContext(ctx, "tcp", conn.cfg.Server); err == nil {
|
||||
|
@ -423,6 +421,17 @@ func (conn *Conn) internalConnect(ctx context.Context) error {
|
|||
} else {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
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 {
|
||||
logging.Info("irc.Connect(): Connecting to %s.", conn.cfg.Server)
|
||||
if s, err := conn.dialer.DialContext(ctx, "tcp", conn.cfg.Server); err == nil {
|
||||
|
|
Loading…
Reference in New Issue