mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Use HTTP to get VATSIM IP in automatic mode
This commit is contained in:
@@ -61,6 +61,9 @@
|
|||||||
"vatsimServerFileUrl": {
|
"vatsimServerFileUrl": {
|
||||||
"url": "https://data.vatsim.net/v3/vatsim-servers.json"
|
"url": "https://data.vatsim.net/v3/vatsim-servers.json"
|
||||||
},
|
},
|
||||||
|
"vatsimFsdHttpUrl": {
|
||||||
|
"url": "http://fsd-http.connect.vatsim.net"
|
||||||
|
},
|
||||||
"vatsimMetarsUrls": {
|
"vatsimMetarsUrls": {
|
||||||
"containerbase": [
|
"containerbase": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1744,6 +1744,13 @@ namespace BlackCore
|
|||||||
return m_setupReader->getSetup().getVatsimServerFileUrl();
|
return m_setupReader->getSetup().getVatsimServerFileUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUrl CApplication::getVatsimFsdHttpUrl() const
|
||||||
|
{
|
||||||
|
if (m_shutdown || !m_setupReader) { return {}; }
|
||||||
|
|
||||||
|
return m_setupReader->getSetup().getVatsimFsdHttpUrl();
|
||||||
|
}
|
||||||
|
|
||||||
void CApplication::onCrashDumpUploadEnabledChanged()
|
void CApplication::onCrashDumpUploadEnabledChanged()
|
||||||
{
|
{
|
||||||
const bool enabled = CBuildConfig::isReleaseBuild() && m_crashDumpSettings.getThreadLocal().isEnabled();
|
const bool enabled = CBuildConfig::isReleaseBuild() && m_crashDumpSettings.getThreadLocal().isEnabled();
|
||||||
|
|||||||
@@ -442,6 +442,9 @@ namespace BlackCore
|
|||||||
//! Get URL to file which contains the list of VATSIM servers
|
//! Get URL to file which contains the list of VATSIM servers
|
||||||
BlackMisc::Network::CUrl getVatsimServerFileUrl() const;
|
BlackMisc::Network::CUrl getVatsimServerFileUrl() const;
|
||||||
|
|
||||||
|
//! Get VATSIM FSD HTTP URL
|
||||||
|
BlackMisc::Network::CUrl getVatsimFsdHttpUrl() const;
|
||||||
|
|
||||||
//! Start services, if not yet parsed call CApplication::parse
|
//! Start services, if not yet parsed call CApplication::parse
|
||||||
virtual bool start();
|
virtual bool start();
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace BlackCore::Data
|
|||||||
m_vatsimStatusFileUrls = CUrlList{ "https://status.vatsim.net" };
|
m_vatsimStatusFileUrls = CUrlList{ "https://status.vatsim.net" };
|
||||||
m_vatsimDataFileUrls = CUrlList{ "https://data.vatsim.net/v3/vatsim-data.json" };
|
m_vatsimDataFileUrls = CUrlList{ "https://data.vatsim.net/v3/vatsim-data.json" };
|
||||||
m_vatsimServerFileUrl = CUrl("https://data.vatsim.net/v3/vatsim-servers.json");
|
m_vatsimServerFileUrl = CUrl("https://data.vatsim.net/v3/vatsim-servers.json");
|
||||||
|
m_vatsimFsdHttpUrl = CUrl("http://fsd-http.connect.vatsim.net");
|
||||||
m_sharedUrls = CUrlList
|
m_sharedUrls = CUrlList
|
||||||
{
|
{
|
||||||
"http://download.swift-project.org/shared/",
|
"http://download.swift-project.org/shared/",
|
||||||
@@ -373,6 +374,7 @@ namespace BlackCore::Data
|
|||||||
case IndexVatsimData: return QVariant::fromValue(m_vatsimDataFileUrls);
|
case IndexVatsimData: return QVariant::fromValue(m_vatsimDataFileUrls);
|
||||||
case IndexVatsimBookings: return QVariant::fromValue(m_vatsimBookingsUrl);
|
case IndexVatsimBookings: return QVariant::fromValue(m_vatsimBookingsUrl);
|
||||||
case IndexVatsimServer: return QVariant::fromValue(m_vatsimServerFileUrl);
|
case IndexVatsimServer: return QVariant::fromValue(m_vatsimServerFileUrl);
|
||||||
|
case IndexVatsimHttpFsd: return QVariant::fromValue(m_vatsimFsdHttpUrl);
|
||||||
case IndexVatsimMetars: return QVariant::fromValue(m_vatsimMetarsUrls);
|
case IndexVatsimMetars: return QVariant::fromValue(m_vatsimMetarsUrls);
|
||||||
case IndexBootstrapFileUrls: return QVariant::fromValue(this->getSwiftBootstrapFileUrls());
|
case IndexBootstrapFileUrls: return QVariant::fromValue(this->getSwiftBootstrapFileUrls());
|
||||||
case IndexUpdateInfoFileUrls: return QVariant::fromValue(this->getSwiftUpdateInfoFileUrls());
|
case IndexUpdateInfoFileUrls: return QVariant::fromValue(this->getSwiftUpdateInfoFileUrls());
|
||||||
@@ -407,6 +409,7 @@ namespace BlackCore::Data
|
|||||||
case IndexVatsimData: m_vatsimDataFileUrls = variant.value<CUrlList>(); break;
|
case IndexVatsimData: m_vatsimDataFileUrls = variant.value<CUrlList>(); break;
|
||||||
case IndexVatsimBookings: m_vatsimBookingsUrl.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexVatsimBookings: m_vatsimBookingsUrl.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexVatsimServer: m_vatsimServerFileUrl = variant.value<CUrl>(); break;
|
case IndexVatsimServer: m_vatsimServerFileUrl = variant.value<CUrl>(); break;
|
||||||
|
case IndexVatsimHttpFsd: m_vatsimFsdHttpUrl = variant.value<CUrl>(); break;
|
||||||
case IndexVatsimMetars: m_vatsimMetarsUrls = variant.value<CUrlList>(); break;
|
case IndexVatsimMetars: m_vatsimMetarsUrls = variant.value<CUrlList>(); break;
|
||||||
case IndexSharedUrls: m_sharedUrls = variant.value<CUrlList>(); break;
|
case IndexSharedUrls: m_sharedUrls = variant.value<CUrlList>(); break;
|
||||||
case IndexOnlineHelpUrls: m_onlineHelpUrls = variant.value<CUrlList>(); break;
|
case IndexOnlineHelpUrls: m_onlineHelpUrls = variant.value<CUrlList>(); break;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace BlackCore::Data
|
|||||||
IndexVatsimMetars,
|
IndexVatsimMetars,
|
||||||
IndexVatsimData,
|
IndexVatsimData,
|
||||||
IndexVatsimServer,
|
IndexVatsimServer,
|
||||||
|
IndexVatsimHttpFsd,
|
||||||
IndexSwiftDbFiles,
|
IndexSwiftDbFiles,
|
||||||
IndexBootstrapFileUrls,
|
IndexBootstrapFileUrls,
|
||||||
IndexUpdateInfoFileUrls,
|
IndexUpdateInfoFileUrls,
|
||||||
@@ -185,6 +186,9 @@ namespace BlackCore::Data
|
|||||||
//! VATSIM server file URL
|
//! VATSIM server file URL
|
||||||
BlackMisc::Network::CUrl getVatsimServerFileUrl() const { return m_vatsimServerFileUrl; }
|
BlackMisc::Network::CUrl getVatsimServerFileUrl() const { return m_vatsimServerFileUrl; }
|
||||||
|
|
||||||
|
//! VATSIM server file URL
|
||||||
|
BlackMisc::Network::CUrl getVatsimFsdHttpUrl() const { return m_vatsimFsdHttpUrl; }
|
||||||
|
|
||||||
//! Help page URL
|
//! Help page URL
|
||||||
//! \remark working URL evaluated at runtime, based on getOnlineHelpUrls
|
//! \remark working URL evaluated at runtime, based on getOnlineHelpUrls
|
||||||
BlackMisc::Network::CUrl getHelpPageUrl(const QString &context = {}) const;
|
BlackMisc::Network::CUrl getHelpPageUrl(const QString &context = {}) const;
|
||||||
@@ -253,7 +257,8 @@ namespace BlackCore::Data
|
|||||||
BlackMisc::Network::CUrlList m_vatsimMetarsUrls; //!< METAR data
|
BlackMisc::Network::CUrlList m_vatsimMetarsUrls; //!< METAR data
|
||||||
BlackMisc::Network::CUrlList m_vatsimStatusFileUrls; //!< Status file, where to find the VATSIM files (METAR, data, ATIS, other status files)
|
BlackMisc::Network::CUrlList m_vatsimStatusFileUrls; //!< Status file, where to find the VATSIM files (METAR, data, ATIS, other status files)
|
||||||
BlackMisc::Network::CUrlList m_vatsimDataFileUrls; //!< Overall VATSIM data file / merely for bootstrapping the first time
|
BlackMisc::Network::CUrlList m_vatsimDataFileUrls; //!< Overall VATSIM data file / merely for bootstrapping the first time
|
||||||
BlackMisc::Network::CUrl m_vatsimServerFileUrl; //!< UR to list of VATSIM servers
|
BlackMisc::Network::CUrl m_vatsimServerFileUrl; //!< URL to list of VATSIM servers
|
||||||
|
BlackMisc::Network::CUrl m_vatsimFsdHttpUrl; //!< URL to HTTP FSD server (for load-balancing and automatic server selection)
|
||||||
BlackMisc::Network::CUrlList m_sharedUrls; //!< where we can obtain shared info files such as bootstrap, ..
|
BlackMisc::Network::CUrlList m_sharedUrls; //!< where we can obtain shared info files such as bootstrap, ..
|
||||||
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
|
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
|
||||||
BlackMisc::Network::CServerList m_predefinedServers; //!< Predefined servers loaded from setup file
|
BlackMisc::Network::CServerList m_predefinedServers; //!< Predefined servers loaded from setup file
|
||||||
@@ -279,6 +284,7 @@ namespace BlackCore::Data
|
|||||||
BLACK_METAMEMBER(vatsimStatusFileUrls),
|
BLACK_METAMEMBER(vatsimStatusFileUrls),
|
||||||
BLACK_METAMEMBER(vatsimDataFileUrls),
|
BLACK_METAMEMBER(vatsimDataFileUrls),
|
||||||
BLACK_METAMEMBER(vatsimServerFileUrl),
|
BLACK_METAMEMBER(vatsimServerFileUrl),
|
||||||
|
BLACK_METAMEMBER(vatsimFsdHttpUrl),
|
||||||
BLACK_METAMEMBER(vatsimBookingsUrl),
|
BLACK_METAMEMBER(vatsimBookingsUrl),
|
||||||
BLACK_METAMEMBER(vatsimMetarsUrls),
|
BLACK_METAMEMBER(vatsimMetarsUrls),
|
||||||
BLACK_METAMEMBER(sharedUrls),
|
BLACK_METAMEMBER(sharedUrls),
|
||||||
|
|||||||
@@ -270,7 +270,39 @@ namespace BlackCore::Fsd
|
|||||||
this->updateConnectionStatus(CConnectionStatus::Connecting);
|
this->updateConnectionStatus(CConnectionStatus::Connecting);
|
||||||
|
|
||||||
const CServer s = this->getServer();
|
const CServer s = this->getServer();
|
||||||
const QString host = s.getAddress();
|
|
||||||
|
QHostAddress serverAddress(s.getAddress());
|
||||||
|
|
||||||
|
if (serverAddress.isNull() && s.getName() == "AUTOMATIC" && s.getEcosystem() == CEcosystem::VATSIM)
|
||||||
|
{
|
||||||
|
// Not an IP -> Get IP for loadbalancing via HTTP
|
||||||
|
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need app");
|
||||||
|
CUrl url = sApp->getVatsimFsdHttpUrl();
|
||||||
|
sApp->getFromNetwork(url, { this, &CFSDClient::handleVatsimServerIpResponse });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QString host = s.getAddress();
|
||||||
|
const quint16 port = static_cast<quint16>(s.getPort());
|
||||||
|
m_socket->connectToHost(host, port);
|
||||||
|
this->startPositionTimers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFSDClient::handleVatsimServerIpResponse(QNetworkReply *nwReplyPtr)
|
||||||
|
{
|
||||||
|
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||||
|
const CServer s = this->getServer();
|
||||||
|
|
||||||
|
QString host = s.getAddress();
|
||||||
|
|
||||||
|
if (nwReply->error() == QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
QHostAddress addr(static_cast<QString>(nwReply->readAll()));
|
||||||
|
if (!addr.isNull()) { host = addr.toString(); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const quint16 port = static_cast<quint16>(s.getPort());
|
const quint16 port = static_cast<quint16>(s.getPort());
|
||||||
m_socket->connectToHost(host, port);
|
m_socket->connectToHost(host, port);
|
||||||
this->startPositionTimers();
|
this->startPositionTimers();
|
||||||
|
|||||||
@@ -58,6 +58,8 @@
|
|||||||
#define PROTOCOL_REVISION_VATSIM_VELOCITY 101
|
#define PROTOCOL_REVISION_VATSIM_VELOCITY 101
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
|
||||||
namespace BlackFsdTest { class CTestFSDClient; }
|
namespace BlackFsdTest { class CTestFSDClient; }
|
||||||
namespace BlackCore::Fsd
|
namespace BlackCore::Fsd
|
||||||
{
|
{
|
||||||
@@ -387,6 +389,8 @@ namespace BlackCore::Fsd
|
|||||||
void handleUnknownPacket(const QStringList &tokens);
|
void handleUnknownPacket(const QStringList &tokens);
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
void handleVatsimServerIpResponse(QNetworkReply *nwReplyPtr);
|
||||||
|
|
||||||
void printSocketError(QAbstractSocket::SocketError socketError);
|
void printSocketError(QAbstractSocket::SocketError socketError);
|
||||||
void handleSocketError(QAbstractSocket::SocketError socketError);
|
void handleSocketError(QAbstractSocket::SocketError socketError);
|
||||||
void handleSocketConnected();
|
void handleSocketConnected();
|
||||||
|
|||||||
Reference in New Issue
Block a user