Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
@@ -86,8 +86,8 @@ Connection::Connection(bool isUserCreatedConnection, qintptr socketDescriptor, Q
connect(m_connectionWorker, &AssetProcessor::ConnectionWorker::ConnectionEstablished, this, &Connection::OnConnectionEstablished, Qt::BlockingQueuedConnection);
connect(m_connectionWorker, &AssetProcessor::ConnectionWorker::ErrorMessage, this, &Connection::ErrorMessage);
connect(m_connectionWorker, &AssetProcessor::ConnectionWorker::IsAddressWhiteListed, this, &Connection::IsAddressWhiteListed);
connect(this, &Connection::AddressIsWhiteListed, m_connectionWorker, &AssetProcessor::ConnectionWorker::AddressIsWhiteListed);
connect(m_connectionWorker, &AssetProcessor::ConnectionWorker::IsAddressInAllowedList, this, &Connection::IsAddressInAllowedList);
connect(this, &Connection::AddressIsInAllowedList, m_connectionWorker, &AssetProcessor::ConnectionWorker::AddressIsInAllowedList);
}
void Connection::Activate(qintptr socketDescriptor)
@@ -202,9 +202,9 @@ Q_SIGNALS:
void Error(unsigned int connId, QString errorString);
// the token is just any identifier to identify a particular connection, potentially from the same host.
// the response (AddressIsWhiteListed) will have the same token as was sent.
void IsAddressWhiteListed(QHostAddress hostAddress, void* token);
void AddressIsWhiteListed(void* token, bool result);
// the response (AddressIsInAllowedList) will have the same token as was sent.
void IsAddressInAllowedList(QHostAddress hostAddress, void* token);
void AddressIsInAllowedList(void* token, bool result);
//metrics
void NumOpenRequestsChanged();
@@ -51,20 +51,20 @@ ConnectionManager::ConnectionManager(QObject* parent)
ConnectionManagerRequestBus::Handler::BusConnect();
QTimer::singleShot(0, this, SLOT(UpdateWhiteListFromBootStrap()));
QTimer::singleShot(0, this, SLOT(UpdateAllowedListFromBootStrap()));
}
void ConnectionManager::UpdateWhiteListFromBootStrap()
void ConnectionManager::UpdateAllowedListFromBootStrap()
{
m_whiteListedAddresses.clear();
QString whitelist = AssetUtilities::ReadWhitelistFromSettingsRegistry();
AZStd::vector<AZStd::string> whitelistaddressList;
AzFramework::StringFunc::Tokenize(whitelist.toUtf8().constData(), whitelistaddressList, ", \t\n\r");
for (const AZStd::string& whitelistaddress : whitelistaddressList)
m_allowedListAddresses.clear();
QString allowedlist = AssetUtilities::ReadAllowedlistFromSettingsRegistry();
AZStd::vector<AZStd::string> allowedlistaddressList;
AzFramework::StringFunc::Tokenize(allowedlist.toUtf8().constData(), allowedlistaddressList, ", \t\n\r");
for (const AZStd::string& allowedlistaddress : allowedlistaddressList)
{
m_whiteListedAddresses << whitelistaddress.c_str();
m_allowedListAddresses << allowedlistaddress.c_str();
}
Q_EMIT SyncWhiteListAndRejectedList(m_whiteListedAddresses, m_rejectedAddresses);
Q_EMIT SyncAllowedListAndRejectedList(m_allowedListAddresses, m_rejectedAddresses);
}
@@ -121,8 +121,8 @@ unsigned int ConnectionManager::internalAddConnection(bool isUserConnection, qin
}
Connection* connection = new Connection(isUserConnection, socketDescriptor, this);
connect(connection, &Connection::IsAddressWhiteListed, this, &ConnectionManager::IsAddressWhiteListed);
connect(this, &ConnectionManager::AddressIsWhiteListed, connection, &Connection::AddressIsWhiteListed);
connect(connection, &Connection::IsAddressInAllowedList, this, &ConnectionManager::IsAddressInAllowedList);
connect(this, &ConnectionManager::AddressIsInAllowedList, connection, &Connection::AddressIsInAllowedList);
connection->SetConnectionId(connectionId);
connect(connection, &Connection::StatusChanged, this, &ConnectionManager::OnStatusChanged);
@@ -496,31 +496,31 @@ void ConnectionManager::NewConnection(qintptr socketDescriptor)
addConnection(socketDescriptor);
}
void ConnectionManager::WhiteListingEnabled(bool enabled)
void ConnectionManager::AllowedListingEnabled(bool enabled)
{
m_whiteListingEnabled = enabled;
m_allowedListingEnabled = enabled;
}
void ConnectionManager::AddWhiteListedAddress(QString address)
void ConnectionManager::AddAddressToAllowedList(QString address)
{
UpdateWhiteListFromBootStrap();
while (m_whiteListedAddresses.removeOne(address)) {}
m_whiteListedAddresses << address;
AssetUtilities::WriteWhitelistToBootstrap(m_whiteListedAddresses);
Q_EMIT SyncWhiteListAndRejectedList(m_whiteListedAddresses, m_rejectedAddresses);
UpdateAllowedListFromBootStrap();
while (m_allowedListAddresses.removeOne(address)) {}
m_allowedListAddresses << address;
AssetUtilities::WriteAllowedlistToBootstrap(m_allowedListAddresses);
Q_EMIT SyncAllowedListAndRejectedList(m_allowedListAddresses, m_rejectedAddresses);
}
void ConnectionManager::RemoveWhiteListedAddress(QString address)
void ConnectionManager::RemoveAddressFromAllowedList(QString address)
{
UpdateWhiteListFromBootStrap();
while (m_whiteListedAddresses.removeOne(address)) {}
AssetUtilities::WriteWhitelistToBootstrap(m_whiteListedAddresses);
Q_EMIT SyncWhiteListAndRejectedList(m_whiteListedAddresses, m_rejectedAddresses);
UpdateAllowedListFromBootStrap();
while (m_allowedListAddresses.removeOne(address)) {}
AssetUtilities::WriteAllowedlistToBootstrap(m_allowedListAddresses);
Q_EMIT SyncAllowedListAndRejectedList(m_allowedListAddresses, m_rejectedAddresses);
}
void ConnectionManager::AddRejectedAddress(QString address, bool surpressWarning)
{
UpdateWhiteListFromBootStrap();
UpdateAllowedListFromBootStrap();
bool alreadyRejected = false;
while (m_rejectedAddresses.removeOne(address)) { alreadyRejected = true; }
m_rejectedAddresses << address;
@@ -528,21 +528,21 @@ void ConnectionManager::AddRejectedAddress(QString address, bool surpressWarning
{
Q_EMIT FirstTimeAddedToRejctedList(address);
}
Q_EMIT SyncWhiteListAndRejectedList(m_whiteListedAddresses, m_rejectedAddresses);
Q_EMIT SyncAllowedListAndRejectedList(m_allowedListAddresses, m_rejectedAddresses);
}
void ConnectionManager::RemoveRejectedAddress(QString address)
{
UpdateWhiteListFromBootStrap();
UpdateAllowedListFromBootStrap();
while (m_rejectedAddresses.removeOne(address)) {}
Q_EMIT SyncWhiteListAndRejectedList(m_whiteListedAddresses, m_rejectedAddresses);
Q_EMIT SyncAllowedListAndRejectedList(m_allowedListAddresses, m_rejectedAddresses);
}
void ConnectionManager::IsAddressWhiteListed(QHostAddress incominghostaddr, void* token)
void ConnectionManager::IsAddressInAllowedList(QHostAddress incominghostaddr, void* token)
{
if (!m_whiteListingEnabled)
if (!m_allowedListingEnabled)
{
Q_EMIT AddressIsWhiteListed(token, true);
Q_EMIT AddressIsInAllowedList(token, true);
return;
}
@@ -550,9 +550,9 @@ void ConnectionManager::IsAddressWhiteListed(QHostAddress incominghostaddr, void
if (incominghostaddr != QHostAddress::Null)
{
// any ipv4 address will be like ::ffff:A.B.C.D, we have to retrieve A.B.C.D for comparision with the whitelisted addresses.
// any ipv4 address will be like ::ffff:A.B.C.D, we have to retrieve A.B.C.D for comparision with the allowedlisted addresses.
// for example Qt will tell us the ipv6 (::ffff:127.0.0.1) for 127.0.0.1,
// but the whitelist below will report ipv4 (127.0.0.1) and ipv6 (::1), and they both won't match to ipv6 (::ffff:127.0.0.1).
// but the allowedlist below will report ipv4 (127.0.0.1) and ipv6 (::1), and they both won't match to ipv6 (::ffff:127.0.0.1).
bool wasConverted = false;
quint32 incomingIPv4 = incominghostaddr.toIPv4Address(&wasConverted);
if (wasConverted)
@@ -567,29 +567,29 @@ void ConnectionManager::IsAddressWhiteListed(QHostAddress incominghostaddr, void
QHostInfo incomingInfo = QHostInfo::fromName(incomingIpAddress);
QString whitelist = AssetUtilities::ReadWhitelistFromSettingsRegistry();
QString allowedlist = AssetUtilities::ReadAllowedlistFromSettingsRegistry();
AZStd::vector<AZStd::string> whitelistaddressList;
AzFramework::StringFunc::Tokenize(whitelist.toUtf8().constData(), whitelistaddressList, ", \t\n\r");
AZStd::vector<AZStd::string> allowedlistaddressList;
AzFramework::StringFunc::Tokenize(allowedlist.toUtf8().constData(), allowedlistaddressList, ", \t\n\r");
// allow localhost, loopback regardless, there's no good reason to accidentally lock yourself out your own computer.
for (const auto& address : QNetworkInterface::allAddresses()) // allAdresses returns the ip address of all local interfaces.
{
whitelistaddressList.push_back(address.toString().toUtf8().constData());
allowedlistaddressList.push_back(address.toString().toUtf8().constData());
}
// does the incoming connection match any entries?
for (const AZStd::string& whitelistaddress : whitelistaddressList)
for (const AZStd::string& allowedListaddress : allowedlistaddressList)
{
//address range matching
size_t maskLocation = whitelistaddress.find('/');
size_t maskLocation = allowedListaddress.find('/');
if (maskLocation != AZStd::string::npos)
{
//x.x.x.x/0 is all addresses
int mask = atoi(whitelistaddress.substr(maskLocation + 1).c_str());
int mask = atoi(allowedListaddress.substr(maskLocation + 1).c_str());
if (mask == 0)
{
Q_EMIT AddressIsWhiteListed(token, true);
Q_EMIT AddressIsInAllowedList(token, true);
return;
}
else
@@ -602,35 +602,35 @@ void ConnectionManager::IsAddressWhiteListed(QHostAddress incominghostaddr, void
//QT should first do a check and see if we are comparing convertible protocols before just early outing.
//If it wasn't convertible to ipv4 then we know it is ipv6 in which case the protocols will match which make this unnecessary, but still correct.
QHostAddress ha(incomingIpAddress);
if (ha.isInSubnet(QHostAddress::parseSubnet(whitelistaddress.c_str())))
if (ha.isInSubnet(QHostAddress::parseSubnet(allowedListaddress.c_str())))
{
Q_EMIT AddressIsWhiteListed(token, true);
Q_EMIT AddressIsInAllowedList(token, true);
return;
}
}
}
else//direct address matching
{
QHostInfo whiteInfo;
QHostAddress whiteHostAddress(whitelistaddress.c_str());
if ((whiteHostAddress.isNull()))
QHostInfo allowedInfo;
QHostAddress allowedHostAddress(allowedListaddress.c_str());
if ((allowedHostAddress.isNull()))
{
whiteInfo = QHostInfo::fromName(QString::fromUtf8(whitelistaddress.c_str()));
allowedInfo = QHostInfo::fromName(QString::fromUtf8(allowedListaddress.c_str()));
}
else
{
QList<QHostAddress> addresses;
addresses << whiteHostAddress;
whiteInfo.setAddresses(addresses);
addresses << allowedHostAddress;
allowedInfo.setAddresses(addresses);
}
for (const auto& whiteAddress : whiteInfo.addresses())
for (const auto& allowedAddress : allowedInfo.addresses())
{
for (const auto& address : incomingInfo.addresses())
{
if (address == whiteAddress)
if (address == allowedAddress)
{
Q_EMIT AddressIsWhiteListed(token, true);
Q_EMIT AddressIsInAllowedList(token, true);
return;
}
}
@@ -639,7 +639,7 @@ void ConnectionManager::IsAddressWhiteListed(QHostAddress incominghostaddr, void
}
AddRejectedAddress(incomingIpAddress);
Q_EMIT AddressIsWhiteListed(token, false);
Q_EMIT AddressIsInAllowedList(token, false);
}
void ConnectionManager::AddBytesReceived(unsigned int connId, qint64 add, bool update)
@@ -109,10 +109,10 @@ Q_SIGNALS:
void ReadyToQuit(QObject* source);
void SyncWhiteListAndRejectedList(QStringList whiteList, QStringList rejectedList);
void SyncAllowedListAndRejectedList(QStringList allowedList, QStringList rejectedList);
// this is a response to the whitelist request with that same token.
void AddressIsWhiteListed(void* token, bool result);
// this is a response to the allowedlist request with that same token.
void AddressIsInAllowedList(void* token, bool result);
void FirstTimeAddedToRejctedList(QString ipAddress);
@@ -123,10 +123,10 @@ public Q_SLOTS:
void MakeSureConnectionMapEmpty();
void NewConnection(qintptr socketDescriptor);
void WhiteListingEnabled(bool enabled);
void IsAddressWhiteListed(QHostAddress hostAddress, void* token);
void AddWhiteListedAddress(QString address);
void RemoveWhiteListedAddress(QString address);
void AllowedListingEnabled(bool enabled);
void IsAddressInAllowedList(QHostAddress hostAddress, void* token);
void AddAddressToAllowedList(QString address);
void RemoveAddressFromAllowedList(QString address);
void AddRejectedAddress(QString address, bool surpressWarning = false);
void RemoveRejectedAddress(QString address);
@@ -185,7 +185,7 @@ public Q_SLOTS:
void OnStatusChanged(unsigned int connId);
void UpdateWhiteListFromBootStrap();
void UpdateAllowedListFromBootStrap();
private:
@@ -205,11 +205,11 @@ private:
// the key is the name of the platform, and the value is the number of those kind of platforms.
QHash<QString, int> m_platformsConnected;
//white listing
bool m_whiteListingEnabled = true;
//allowed listing
bool m_allowedListingEnabled = true;
//these lists are just caches, only used for updating
QStringList m_whiteListedAddresses;
QStringList m_allowedListAddresses;
QStringList m_rejectedAddresses;
};
@@ -378,11 +378,11 @@ void ConnectionWorker::ConnectSocket(qintptr socketDescriptor)
disconnect(&m_engineSocket, &QTcpSocket::stateChanged, this, &ConnectionWorker::EngineSocketStateChanged);
m_engineSocket.setSocketDescriptor(socketDescriptor, QAbstractSocket::ConnectedState, QIODevice::ReadWrite);
Q_EMIT IsAddressWhiteListed(m_engineSocket.peerAddress(), reinterpret_cast<void*>(this));
Q_EMIT IsAddressInAllowedList(m_engineSocket.peerAddress(), reinterpret_cast<void*>(this));
}
}
void ConnectionWorker::AddressIsWhiteListed(void* token, bool result)
void ConnectionWorker::AddressIsInAllowedList(void* token, bool result)
{
if (reinterpret_cast<void*>(this) == token)
{
@@ -395,7 +395,7 @@ void ConnectionWorker::AddressIsWhiteListed(void* token, bool result)
else
{
// this address has been rejected, disconnect immediately!!!
AZ_TracePrintf(AssetProcessor::ConsoleChannel, " A connection attempt was ignored because it is not whitelisted. Please consider adding white_list=(IP ADDRESS),localhost to the bootstrap.cfg");
AZ_TracePrintf(AssetProcessor::ConsoleChannel, " A connection attempt was ignored because it is not in the allowed list. Please consider adding allowed_list=(IP ADDRESS),localhost to the bootstrap.cfg");
disconnect(&m_engineSocket, &QTcpSocket::readyRead, this, &ConnectionWorker::EngineSocketHasData);
@@ -58,7 +58,7 @@ Q_SIGNALS:
void ErrorMessage(QString msg);
// the token identifies the unique connection instance, since multiple may have the same address
void IsAddressWhiteListed(QHostAddress hostAddress, void* token);
void IsAddressInAllowedList(QHostAddress hostAddress, void* token);
public Q_SLOTS:
void ConnectSocket(qintptr socketDescriptor);
@@ -70,8 +70,8 @@ Q_SIGNALS:
void RequestTerminate();
bool NegotiateDirect(bool initiate);
// the token will be the same token sent in the whitelisting request.
void AddressIsWhiteListed(void* token, bool result);
// the token will be the same token sent in the allowedlisting request.
void AddressIsInAllowedList(void* token, bool result);
private Q_SLOTS:
void TerminateConnection();