mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 14:56:42 +00:00
Turning off IMAP server while no connection
This commit is contained in:
@ -102,6 +102,9 @@ type ClientConfig struct {
|
||||
// MinBytesPerSecond specifies minimum Bytes per second or the request will be canceled.
|
||||
// Zero means no limitation.
|
||||
MinBytesPerSecond int64
|
||||
|
||||
NoConnectionHandler func()
|
||||
ConnectionHandler func()
|
||||
}
|
||||
|
||||
// client is a client of the protonmail API. It implements the Client interface.
|
||||
|
||||
@ -37,7 +37,17 @@ func NewProxyTLSDialer(dialer TLSDialer, cm *ClientManager) *ProxyTLSDialer {
|
||||
}
|
||||
|
||||
// DialTLS dials the given network/address. If it fails, it retries using a proxy.
|
||||
func (d *ProxyTLSDialer) DialTLS(network, address string) (conn net.Conn, err error) {
|
||||
func (d *ProxyTLSDialer) DialTLS(network, address string) (net.Conn, error) {
|
||||
conn, err := d.dialTLS(network, address)
|
||||
if err != nil {
|
||||
d.cm.config.NoConnectionHandler()
|
||||
} else {
|
||||
d.cm.config.ConnectionHandler()
|
||||
}
|
||||
return conn, err
|
||||
}
|
||||
|
||||
func (d *ProxyTLSDialer) dialTLS(network, address string) (conn net.Conn, err error) {
|
||||
if conn, err = d.dialer.DialTLS(network, address); err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user