mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 08:15:37 +00:00
fix XML processing
This commit is contained in:
parent
0249ce7043
commit
af607bd8a2
10
nvhttp.cpp
10
nvhttp.cpp
@ -1,5 +1,6 @@
|
|||||||
#include "nvhttp.h"
|
#include "nvhttp.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
@ -160,11 +161,16 @@ NvHTTP::getXmlString(QString xml,
|
|||||||
{
|
{
|
||||||
QXmlStreamReader xmlReader(xml);
|
QXmlStreamReader xmlReader(xml);
|
||||||
|
|
||||||
while (xmlReader.readNextStartElement())
|
while (!xmlReader.atEnd())
|
||||||
{
|
{
|
||||||
|
if (xmlReader.readNext() != QXmlStreamReader::StartElement)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (xmlReader.name() == tagName)
|
if (xmlReader.name() == tagName)
|
||||||
{
|
{
|
||||||
return xmlReader.text().toString();
|
return xmlReader.readElementText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ NvPairingManager::NvPairingManager(QString address, IdentityManager im) :
|
|||||||
m_Http(address, im),
|
m_Http(address, im),
|
||||||
m_Im(im)
|
m_Im(im)
|
||||||
{
|
{
|
||||||
BIO *bio = BIO_new_mem_buf(m_Im.getCertificate().toStdString().c_str(), -1);
|
QByteArray cert = m_Im.getCertificate();
|
||||||
|
BIO *bio = BIO_new_mem_buf(cert.data(), -1);
|
||||||
THROW_BAD_ALLOC_IF_NULL(bio);
|
THROW_BAD_ALLOC_IF_NULL(bio);
|
||||||
|
|
||||||
m_Cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr);
|
m_Cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr);
|
||||||
@ -24,7 +25,8 @@ NvPairingManager::NvPairingManager(QString address, IdentityManager im) :
|
|||||||
throw new std::runtime_error("Unable to load certificate");
|
throw new std::runtime_error("Unable to load certificate");
|
||||||
}
|
}
|
||||||
|
|
||||||
bio = BIO_new_mem_buf(m_Im.getPrivateKey().toStdString().c_str(), -1);
|
QByteArray pk = m_Im.getPrivateKey();
|
||||||
|
bio = BIO_new_mem_buf(pk.data(), -1);
|
||||||
THROW_BAD_ALLOC_IF_NULL(bio);
|
THROW_BAD_ALLOC_IF_NULL(bio);
|
||||||
|
|
||||||
PEM_read_bio_PrivateKey(bio, &m_PrivateKey, nullptr, nullptr);
|
PEM_read_bio_PrivateKey(bio, &m_PrivateKey, nullptr, nullptr);
|
||||||
@ -167,6 +169,7 @@ NvPairingManager::pair(QString serverInfo, QString pin)
|
|||||||
"devicename=roth&updateState=1&phrase=getservercert&salt=" +
|
"devicename=roth&updateState=1&phrase=getservercert&salt=" +
|
||||||
salt.toHex() + "&clientcert=" + m_Im.getCertificate().toHex(),
|
salt.toHex() + "&clientcert=" + m_Im.getCertificate().toHex(),
|
||||||
false);
|
false);
|
||||||
|
m_Http.verifyResponseStatus(getCert);
|
||||||
if (m_Http.getXmlString(getCert, "paired") != "1")
|
if (m_Http.getXmlString(getCert, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #1";
|
qDebug() << "Failed pairing at stage #1";
|
||||||
@ -179,6 +182,7 @@ NvPairingManager::pair(QString serverInfo, QString pin)
|
|||||||
"devicename=roth&updateState=1&clientchallenge=" +
|
"devicename=roth&updateState=1&clientchallenge=" +
|
||||||
encryptedChallenge.toHex(),
|
encryptedChallenge.toHex(),
|
||||||
true);
|
true);
|
||||||
|
m_Http.verifyResponseStatus(challengeXml);
|
||||||
if (m_Http.getXmlString(challengeXml, "paired") != "1")
|
if (m_Http.getXmlString(challengeXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #2";
|
qDebug() << "Failed pairing at stage #2";
|
||||||
@ -204,6 +208,7 @@ NvPairingManager::pair(QString serverInfo, QString pin)
|
|||||||
"devicename=roth&updateState=1&serverchallengeresp=" +
|
"devicename=roth&updateState=1&serverchallengeresp=" +
|
||||||
encryptedChallengeResponseHash.toHex(),
|
encryptedChallengeResponseHash.toHex(),
|
||||||
true);
|
true);
|
||||||
|
m_Http.verifyResponseStatus(respXml);
|
||||||
if (m_Http.getXmlString(respXml, "paired") != "1")
|
if (m_Http.getXmlString(respXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #3";
|
qDebug() << "Failed pairing at stage #3";
|
||||||
@ -229,6 +234,7 @@ NvPairingManager::pair(QString serverInfo, QString pin)
|
|||||||
"devicename=roth&updateState=1&clientpairingsecret=" +
|
"devicename=roth&updateState=1&clientpairingsecret=" +
|
||||||
clientPairingSecret.toHex(),
|
clientPairingSecret.toHex(),
|
||||||
true);
|
true);
|
||||||
|
m_Http.verifyResponseStatus(secretRespXml);
|
||||||
if (m_Http.getXmlString(secretRespXml, "paired") != "1")
|
if (m_Http.getXmlString(secretRespXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #4";
|
qDebug() << "Failed pairing at stage #4";
|
||||||
@ -239,6 +245,7 @@ NvPairingManager::pair(QString serverInfo, QString pin)
|
|||||||
"pair",
|
"pair",
|
||||||
"devicename=roth&updateState=1&phase=pairchallenge",
|
"devicename=roth&updateState=1&phase=pairchallenge",
|
||||||
true);
|
true);
|
||||||
|
m_Http.verifyResponseStatus(pairChallengeXml);
|
||||||
if (m_Http.getXmlString(pairChallengeXml, "paired") != "1")
|
if (m_Http.getXmlString(pairChallengeXml, "paired") != "1")
|
||||||
{
|
{
|
||||||
qDebug() << "Failed pairing at stage #5";
|
qDebug() << "Failed pairing at stage #5";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user