mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-10 21:54:17 +00:00
Fix priority and formatting on many debug messages
This commit is contained in:
parent
7c74cdc50b
commit
b16aac0c06
4 changed files with 25 additions and 22 deletions
|
@ -140,12 +140,12 @@ NvComputer::NvComputer(QString address, QString serverInfo)
|
||||||
bool NvComputer::wake()
|
bool NvComputer::wake()
|
||||||
{
|
{
|
||||||
if (state == NvComputer::CS_ONLINE) {
|
if (state == NvComputer::CS_ONLINE) {
|
||||||
qWarning() << name << " is already online";
|
qWarning() << name << "is already online";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (macAddress.isNull()) {
|
if (macAddress.isNull()) {
|
||||||
qWarning() << name << " has no MAC address stored";
|
qWarning() << name << "has no MAC address stored";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ bool NvComputer::wake()
|
||||||
// Send to all ports
|
// Send to all ports
|
||||||
for (quint16 port : WOL_PORTS) {
|
for (quint16 port : WOL_PORTS) {
|
||||||
if (sock.writeDatagram(wolPayload, address, port)) {
|
if (sock.writeDatagram(wolPayload, address, port)) {
|
||||||
qDebug() << "Send WoL packet to " << name << " via " << address.toString() << ":" << port;
|
qInfo().nospace().noquote() << "Send WoL packet to " << name << " via " << address.toString() << ":" << port;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ void ComputerManager::startPolling()
|
||||||
m_MdnsBrowser = new QMdnsEngine::Browser(&m_MdnsServer, "_nvstream._tcp.local.", &m_MdnsCache);
|
m_MdnsBrowser = new QMdnsEngine::Browser(&m_MdnsServer, "_nvstream._tcp.local.", &m_MdnsCache);
|
||||||
connect(m_MdnsBrowser, &QMdnsEngine::Browser::serviceAdded,
|
connect(m_MdnsBrowser, &QMdnsEngine::Browser::serviceAdded,
|
||||||
this, [this](const QMdnsEngine::Service& service) {
|
this, [this](const QMdnsEngine::Service& service) {
|
||||||
qDebug() << "Discovered mDNS host: " << service.hostname();
|
qInfo() << "Discovered mDNS host:" << service.hostname();
|
||||||
|
|
||||||
MdnsPendingComputer* pendingComputer = new MdnsPendingComputer(&m_MdnsServer, &m_MdnsCache, service);
|
MdnsPendingComputer* pendingComputer = new MdnsPendingComputer(&m_MdnsServer, &m_MdnsCache, service);
|
||||||
connect(pendingComputer, SIGNAL(resolvedv4(MdnsPendingComputer*,QHostAddress)),
|
connect(pendingComputer, SIGNAL(resolvedv4(MdnsPendingComputer*,QHostAddress)),
|
||||||
|
@ -381,7 +381,7 @@ void ComputerManager::startPolling()
|
||||||
void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer,
|
void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer,
|
||||||
const QHostAddress& address)
|
const QHostAddress& address)
|
||||||
{
|
{
|
||||||
qDebug() << "Resolved " << computer->hostname() << " to " << address.toString();
|
qInfo() << "Resolved" << computer->hostname() << "to" << address.toString();
|
||||||
|
|
||||||
addNewHost(address.toString(), true);
|
addNewHost(address.toString(), true);
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ void IdentityManager::createCredentials(QSettings& settings)
|
||||||
settings.setValue(SER_CERT, m_CachedPemCert);
|
settings.setValue(SER_CERT, m_CachedPemCert);
|
||||||
settings.setValue(SER_KEY, m_CachedPrivateKey);
|
settings.setValue(SER_KEY, m_CachedPrivateKey);
|
||||||
|
|
||||||
qDebug() << "Wrote new identity credentials to settings";
|
qInfo() << "Wrote new identity credentials to settings";
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentityManager::IdentityManager()
|
IdentityManager::IdentityManager()
|
||||||
|
@ -112,7 +112,7 @@ IdentityManager::IdentityManager()
|
||||||
m_CachedPrivateKey = settings.value(SER_KEY).toByteArray();
|
m_CachedPrivateKey = settings.value(SER_KEY).toByteArray();
|
||||||
|
|
||||||
if (m_CachedPemCert.isEmpty() || m_CachedPrivateKey.isEmpty()) {
|
if (m_CachedPemCert.isEmpty() || m_CachedPrivateKey.isEmpty()) {
|
||||||
qDebug() << "No existing credentials found";
|
qInfo() << "No existing credentials found";
|
||||||
createCredentials(settings);
|
createCredentials(settings);
|
||||||
}
|
}
|
||||||
else if (getSslCertificate().isNull()) {
|
else if (getSslCertificate().isNull()) {
|
||||||
|
@ -191,7 +191,7 @@ IdentityManager::getUniqueId()
|
||||||
// Load the unique ID from settings
|
// Load the unique ID from settings
|
||||||
m_CachedUniqueId = settings.value(SER_UNIQUEID).toString();
|
m_CachedUniqueId = settings.value(SER_UNIQUEID).toString();
|
||||||
if (!m_CachedUniqueId.isEmpty() && !m_CachedUniqueId.isNull()) {
|
if (!m_CachedUniqueId.isEmpty() && !m_CachedUniqueId.isNull()) {
|
||||||
qDebug() << "Loaded unique ID from settings: " << m_CachedUniqueId;
|
qInfo() << "Loaded unique ID from settings:" << m_CachedUniqueId;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Generate a new unique ID in base 16
|
// Generate a new unique ID in base 16
|
||||||
|
@ -199,7 +199,7 @@ IdentityManager::getUniqueId()
|
||||||
RAND_bytes(reinterpret_cast<unsigned char*>(&uid), sizeof(uid));
|
RAND_bytes(reinterpret_cast<unsigned char*>(&uid), sizeof(uid));
|
||||||
m_CachedUniqueId = QString::number(uid, 16);
|
m_CachedUniqueId = QString::number(uid, 16);
|
||||||
|
|
||||||
qDebug() << "Generated new unique ID: " << m_CachedUniqueId;
|
qInfo() << "Generated new unique ID:" << m_CachedUniqueId;
|
||||||
|
|
||||||
settings.setValue(SER_UNIQUEID, m_CachedUniqueId);
|
settings.setValue(SER_UNIQUEID, m_CachedUniqueId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,10 @@ NvHTTP::verifyResponseStatus(QString xml)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString statusMessage = xmlReader.attributes().value("status_message").toString();
|
QString statusMessage = xmlReader.attributes().value("status_message").toString();
|
||||||
qDebug() << "Request failed: " << statusCode << " " << statusMessage;
|
if (statusCode != 401) {
|
||||||
|
// 401 is expected for unpaired PCs when we fetch serverinfo over HTTPS
|
||||||
|
qWarning() << "Request failed:" << statusCode << statusMessage;
|
||||||
|
}
|
||||||
throw GfeHttpResponseException(statusCode, statusMessage);
|
throw GfeHttpResponseException(statusCode, statusMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,13 +379,13 @@ NvHTTP::openConnection(QUrl baseUrl,
|
||||||
{
|
{
|
||||||
QTimer::singleShot(REQUEST_TIMEOUT_MS, &loop, SLOT(quit()));
|
QTimer::singleShot(REQUEST_TIMEOUT_MS, &loop, SLOT(quit()));
|
||||||
}
|
}
|
||||||
qDebug() << "Executing request: " << url.toString();
|
qInfo() << "Executing request:" << url.toString();
|
||||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||||
|
|
||||||
// Abort the request if it timed out
|
// Abort the request if it timed out
|
||||||
if (!reply->isFinished())
|
if (!reply->isFinished())
|
||||||
{
|
{
|
||||||
qDebug() << "Aborting timed out request for " << url.toString();
|
qWarning() << "Aborting timed out request for" << url.toString();
|
||||||
reply->abort();
|
reply->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +396,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
||||||
// Handle error
|
// Handle error
|
||||||
if (reply->error() != QNetworkReply::NoError)
|
if (reply->error() != QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
qDebug() << command << " request failed with error " << reply->error();
|
qWarning() << command << " request failed with error " << reply->error();
|
||||||
GfeHttpResponseException exception(reply->error(), reply->errorString());
|
GfeHttpResponseException exception(reply->error(), reply->errorString());
|
||||||
delete reply;
|
delete reply;
|
||||||
throw exception;
|
throw exception;
|
||||||
|
|
|
@ -164,7 +164,7 @@ NvPairingManager::PairState
|
||||||
NvPairingManager::pair(QString appVersion, QString pin)
|
NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
{
|
{
|
||||||
int serverMajorVersion = NvHTTP::parseQuad(appVersion).at(0);
|
int serverMajorVersion = NvHTTP::parseQuad(appVersion).at(0);
|
||||||
qDebug() << "Pairing with server generation: " << serverMajorVersion;
|
qInfo() << "Pairing with server generation:" << serverMajorVersion;
|
||||||
|
|
||||||
QCryptographicHash::Algorithm hashAlgo;
|
QCryptographicHash::Algorithm hashAlgo;
|
||||||
int hashLength;
|
int hashLength;
|
||||||
|
@ -196,14 +196,14 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
NvHTTP::verifyResponseStatus(getCert);
|
NvHTTP::verifyResponseStatus(getCert);
|
||||||
if (NvHTTP::getXmlString(getCert, "paired") != "1")
|
if (NvHTTP::getXmlString(getCert, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #1";
|
qCritical() << "Failed pairing at stage #1";
|
||||||
return PairState::FAILED;
|
return PairState::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray serverCert = NvHTTP::getXmlStringFromHex(getCert, "plaincert");
|
QByteArray serverCert = NvHTTP::getXmlStringFromHex(getCert, "plaincert");
|
||||||
if (serverCert == nullptr)
|
if (serverCert == nullptr)
|
||||||
{
|
{
|
||||||
qDebug() << "Server likely already pairing";
|
qCritical() << "Server likely already pairing";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::ALREADY_IN_PROGRESS;
|
return PairState::ALREADY_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
NvHTTP::verifyResponseStatus(challengeXml);
|
NvHTTP::verifyResponseStatus(challengeXml);
|
||||||
if (NvHTTP::getXmlString(challengeXml, "paired") != "1")
|
if (NvHTTP::getXmlString(challengeXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #2";
|
qCritical() << "Failed pairing at stage #2";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::FAILED;
|
return PairState::FAILED;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
NvHTTP::verifyResponseStatus(respXml);
|
NvHTTP::verifyResponseStatus(respXml);
|
||||||
if (NvHTTP::getXmlString(respXml, "paired") != "1")
|
if (NvHTTP::getXmlString(respXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #3";
|
qCritical() << "Failed pairing at stage #3";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::FAILED;
|
return PairState::FAILED;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
serverSignature,
|
serverSignature,
|
||||||
serverCert))
|
serverCert))
|
||||||
{
|
{
|
||||||
qDebug() << "MITM detected";
|
qCritical() << "MITM detected";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::FAILED;
|
return PairState::FAILED;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
expectedResponseData.append(serverSecret);
|
expectedResponseData.append(serverSecret);
|
||||||
if (QCryptographicHash::hash(expectedResponseData, hashAlgo) != serverResponse)
|
if (QCryptographicHash::hash(expectedResponseData, hashAlgo) != serverResponse)
|
||||||
{
|
{
|
||||||
qDebug() << "Incorrect PIN";
|
qCritical() << "Incorrect PIN";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::PIN_WRONG;
|
return PairState::PIN_WRONG;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
NvHTTP::verifyResponseStatus(secretRespXml);
|
NvHTTP::verifyResponseStatus(secretRespXml);
|
||||||
if (NvHTTP::getXmlString(secretRespXml, "paired") != "1")
|
if (NvHTTP::getXmlString(secretRespXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #4";
|
qCritical() << "Failed pairing at stage #4";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::FAILED;
|
return PairState::FAILED;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||||
NvHTTP::verifyResponseStatus(pairChallengeXml);
|
NvHTTP::verifyResponseStatus(pairChallengeXml);
|
||||||
if (NvHTTP::getXmlString(pairChallengeXml, "paired") != "1")
|
if (NvHTTP::getXmlString(pairChallengeXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #5";
|
qCritical() << "Failed pairing at stage #5";
|
||||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||||
return PairState::FAILED;
|
return PairState::FAILED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue