mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Improve SMTP code logging to facilite debug
This commit is contained in:
parent
58bfa6f1bb
commit
037cc655ba
30
src/smtp.cpp
30
src/smtp.cpp
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "smtp.h"
|
#include "smtp.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
#include "qbtsession.h"
|
||||||
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
@ -161,8 +162,7 @@ void Smtp::readyRead()
|
|||||||
// Connection was successful
|
// Connection was successful
|
||||||
ehlo();
|
ehlo();
|
||||||
} else {
|
} else {
|
||||||
// TODO: Log something
|
logError("Connection failed, unrecognized reply: "+line);
|
||||||
qDebug() << "Connection failed, unrecognized reply:" << line;
|
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -191,14 +191,13 @@ void Smtp::readyRead()
|
|||||||
case AuthSent:
|
case AuthSent:
|
||||||
case Authenticated:
|
case Authenticated:
|
||||||
if (code[0] == '2') {
|
if (code[0] == '2') {
|
||||||
qDebug() << "Login was OK, send <mail from>...";
|
qDebug() << "Sending <mail from>...";
|
||||||
socket->write("mail from:<" + from.toAscii() + ">\r\n");
|
socket->write("mail from:<" + from.toAscii() + ">\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
state = Rcpt;
|
state = Rcpt;
|
||||||
} else {
|
} else {
|
||||||
// Authentication failed!
|
// Authentication failed!
|
||||||
// TODO: Log something
|
logError("Authentication failed, msg: "+line);
|
||||||
qDebug() << "Authentication not sent properly, aborting";
|
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -208,7 +207,7 @@ void Smtp::readyRead()
|
|||||||
socket->flush();
|
socket->flush();
|
||||||
state = Data;
|
state = Data;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "<Mail from> not sent properly, aborting";
|
logError("<mail from> was rejected by server, msg: "+line);
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -218,7 +217,7 @@ void Smtp::readyRead()
|
|||||||
socket->flush();
|
socket->flush();
|
||||||
state = Body;
|
state = Body;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "<Rcpt to> not sent properly, aborting";
|
logError("<Rcpt to> was rejected by server, msg: "+line);
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -228,7 +227,7 @@ void Smtp::readyRead()
|
|||||||
socket->flush();
|
socket->flush();
|
||||||
state = Quit;
|
state = Quit;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "data not sent properly, aborting";
|
logError("<data> was rejected by server, msg: "+line);
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -239,7 +238,7 @@ void Smtp::readyRead()
|
|||||||
// here, we just close.
|
// here, we just close.
|
||||||
state = Close;
|
state = Close;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Message not sent properly, aborting";
|
logError("Message was rejected by the server, error: "+line);
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -319,8 +318,7 @@ void Smtp::parseEhloResponse(const QByteArray& code, bool continued, const QStri
|
|||||||
} else {
|
} else {
|
||||||
// Both EHLO and HELO failed, chances are this is NOT
|
// Both EHLO and HELO failed, chances are this is NOT
|
||||||
// a SMTP server
|
// a SMTP server
|
||||||
// TODO: log something
|
logError("Both EHLO and HELO failed, msg: "+line);
|
||||||
qDebug() << "Both EHLO and HELO failed, aborting.";
|
|
||||||
state = Close;
|
state = Close;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -379,7 +377,9 @@ void Smtp::authenticate()
|
|||||||
authLogin();
|
authLogin();
|
||||||
} else {
|
} else {
|
||||||
// Skip authentication
|
// Skip authentication
|
||||||
qDebug() << "Server does not support any of our AUTH modes, skip authentication...";
|
logError("The SMTP server does not seem to support any of the authentications modes "
|
||||||
|
"we support [CRAM-MD5|PLAIN|LOGIN], skipping authentication, "
|
||||||
|
"knowing it is likely to fail... Server Auth Modes: "+auth.join("|"));
|
||||||
state = Authenticated;
|
state = Authenticated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,3 +450,9 @@ void Smtp::authLogin()
|
|||||||
state = AuthSent;
|
state = AuthSent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Smtp::logError(const QString &msg)
|
||||||
|
{
|
||||||
|
qDebug() << "Email Notification Error:" << msg;
|
||||||
|
QBtSession::instance()->addConsoleMessage("Email Notification Error: "+msg, "red");
|
||||||
|
}
|
||||||
|
@ -70,6 +70,7 @@ private:
|
|||||||
void authCramMD5(const QByteArray& challenge = QByteArray());
|
void authCramMD5(const QByteArray& challenge = QByteArray());
|
||||||
void authPlain();
|
void authPlain();
|
||||||
void authLogin();
|
void authLogin();
|
||||||
|
void logError(const QString &msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum states { Rcpt, EhloSent, HeloSent, EhloDone, EhloGreetReceived, AuthRequestSent, AuthSent,
|
enum states { Rcpt, EhloSent, HeloSent, EhloDone, EhloGreetReceived, AuthRequestSent, AuthSent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user