Log IMAP/SMTP connection time in debug mode

pull/6566/head
Aleksander Machniak 6 years ago
parent 00e53fac53
commit 943de28d2a

@ -978,6 +978,14 @@ class rcube_imap_generic
$this->prefs['timeout'] = max(0, intval(ini_get('default_socket_timeout')));
}
if ($this->debug) {
// set connection identifier for debug output
$this->resourceid = strtoupper(substr(md5(microtime() . $host . $this->user), 0, 4));
$_host = ($this->prefs['ssl_mode'] == 'tls' ? 'tls://' : '') . $host . ':' . $this->prefs['port'];
$this->debug("Connecting to $_host...");
}
if (!empty($this->prefs['socket_options'])) {
$context = stream_context_create($this->prefs['socket_options']);
$this->fp = stream_socket_client($host . ':' . $this->prefs['port'], $errno, $errstr,
@ -1000,14 +1008,8 @@ class rcube_imap_generic
$line = trim(fgets($this->fp, 8192));
if ($this->debug) {
// set connection identifier for debug output
preg_match('/#([0-9]+)/', (string) $this->fp, $m);
$this->resourceid = strtoupper(substr(md5($m[1].$this->user.microtime()), 0, 4));
if ($line) {
$this->debug('S: '. $line);
}
if ($this->debug && $line) {
$this->debug('S: '. $line);
}
// Connected to wrong port or connection error?

@ -114,6 +114,9 @@ class rcube_smtp
if ($rcube->config->get('smtp_debug')) {
$this->conn->setDebug(true, array($this, 'debug_handler'));
$this->anonymize_log = 0;
$_host = ($use_tls ? 'tls://' : '') . $smtp_host . ':' . $smtp_port;
$this->debug_handler($this->conn, "Connecting to $_host...");
}
// register authentication methods

Loading…
Cancel
Save