mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
re-gen the interface keypair while being denied from domain
This commit is contained in:
parent
540d1615cd
commit
6cab831ea0
8 changed files with 55 additions and 54 deletions
|
@ -926,9 +926,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
SpacemouseManager::getInstance().init();
|
SpacemouseManager::getInstance().init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
|
||||||
packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
|
|
||||||
|
|
||||||
// If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
|
// If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
|
||||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||||
connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
|
connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
|
||||||
|
@ -3961,30 +3958,10 @@ void Application::clearDomainOctreeDetails() {
|
||||||
void Application::domainChanged(const QString& domainHostname) {
|
void Application::domainChanged(const QString& domainHostname) {
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
clearDomainOctreeDetails();
|
clearDomainOctreeDetails();
|
||||||
_domainConnectionRefusals.clear();
|
|
||||||
// disable physics until we have enough information about our new location to not cause craziness.
|
// disable physics until we have enough information about our new location to not cause craziness.
|
||||||
_physicsEnabled = false;
|
_physicsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::handleDomainConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message) {
|
|
||||||
// Read deny reason from packet
|
|
||||||
quint16 reasonSize;
|
|
||||||
message->readPrimitive(&reasonSize);
|
|
||||||
QString reason = QString::fromUtf8(message->readWithoutCopy(reasonSize));
|
|
||||||
|
|
||||||
// output to the log so the user knows they got a denied connection request
|
|
||||||
// and check and signal for an access token so that we can make sure they are logged in
|
|
||||||
qCDebug(interfaceapp) << "The domain-server denied a connection request: " << reason;
|
|
||||||
qCDebug(interfaceapp) << "You may need to re-log to generate a keypair so you can provide a username signature.";
|
|
||||||
|
|
||||||
if (!_domainConnectionRefusals.contains(reason)) {
|
|
||||||
_domainConnectionRefusals.append(reason);
|
|
||||||
emit domainConnectionRefused(reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountManager::getInstance().checkAndSignalForAccessToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::connectedToDomain(const QString& hostname) {
|
void Application::connectedToDomain(const QString& hostname) {
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
const QUuid& domainID = DependencyManager::get<NodeList>()->getDomainHandler().getUUID();
|
const QUuid& domainID = DependencyManager::get<NodeList>()->getDomainHandler().getUUID();
|
||||||
|
|
|
@ -223,7 +223,6 @@ signals:
|
||||||
void svoImportRequested(const QString& url);
|
void svoImportRequested(const QString& url);
|
||||||
|
|
||||||
void checkBackgroundDownloads();
|
void checkBackgroundDownloads();
|
||||||
void domainConnectionRefused(const QString& reason);
|
|
||||||
|
|
||||||
void fullAvatarURLChanged(const QString& newValue, const QString& modelName);
|
void fullAvatarURLChanged(const QString& newValue, const QString& modelName);
|
||||||
|
|
||||||
|
@ -291,8 +290,6 @@ private slots:
|
||||||
void activeChanged(Qt::ApplicationState state);
|
void activeChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
||||||
void handleDomainConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message);
|
|
||||||
|
|
||||||
void notifyPacketVersionMismatch();
|
void notifyPacketVersionMismatch();
|
||||||
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
@ -472,7 +469,6 @@ private:
|
||||||
typedef bool (Application::* AcceptURLMethod)(const QString &);
|
typedef bool (Application::* AcceptURLMethod)(const QString &);
|
||||||
static const QHash<QString, AcceptURLMethod> _acceptedExtensions;
|
static const QHash<QString, AcceptURLMethod> _acceptedExtensions;
|
||||||
|
|
||||||
QList<QString> _domainConnectionRefusals;
|
|
||||||
glm::uvec2 _renderResolution;
|
glm::uvec2 _renderResolution;
|
||||||
|
|
||||||
int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS;
|
int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
WindowScriptingInterface::WindowScriptingInterface() {
|
WindowScriptingInterface::WindowScriptingInterface() {
|
||||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
||||||
connect(qApp, &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
|
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
|
||||||
|
|
||||||
connect(qApp, &Application::svoImportRequested, [this](const QString& urlString) {
|
connect(qApp, &Application::svoImportRequested, [this](const QString& urlString) {
|
||||||
static const QMetaMethod svoImportRequestedSignal =
|
static const QMetaMethod svoImportRequestedSignal =
|
||||||
|
|
|
@ -83,20 +83,6 @@ AccountManager::AccountManager() :
|
||||||
connect(&_accountInfo, &DataServerAccountInfo::balanceChanged, this, &AccountManager::accountInfoBalanceChanged);
|
connect(&_accountInfo, &DataServerAccountInfo::balanceChanged, this, &AccountManager::accountInfoBalanceChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::setIsAgent(bool isAgent) {
|
|
||||||
if (_isAgent != isAgent) {
|
|
||||||
_isAgent = isAgent;
|
|
||||||
|
|
||||||
if (_isAgent) {
|
|
||||||
// any profile changes in account manager should generate a new keypair
|
|
||||||
connect(this, &AccountManager::profileChanged, this, &AccountManager::generateNewUserKeypair);
|
|
||||||
} else {
|
|
||||||
// disconnect the generation of a new keypair during profile changes
|
|
||||||
disconnect(this, &AccountManager::profileChanged, this, &AccountManager::generateNewUserKeypair);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString DOUBLE_SLASH_SUBSTITUTE = "slashslash";
|
const QString DOUBLE_SLASH_SUBSTITUTE = "slashslash";
|
||||||
|
|
||||||
void AccountManager::logout() {
|
void AccountManager::logout() {
|
||||||
|
@ -203,13 +189,9 @@ void AccountManager::setAuthURL(const QUrl& authURL) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isAgent && !_accountInfo.getAccessToken().token.isEmpty()) {
|
if (_isAgent && !_accountInfo.getAccessToken().token.isEmpty() && !_accountInfo.hasProfile()) {
|
||||||
// profile info isn't guaranteed to be saved too
|
// we are missing profile information, request it now
|
||||||
if (_accountInfo.hasProfile()) {
|
requestProfile();
|
||||||
emit profileChanged();
|
|
||||||
} else {
|
|
||||||
requestProfile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell listeners that the auth endpoint has changed
|
// tell listeners that the auth endpoint has changed
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
QHttpMultiPart* dataMultiPart = NULL,
|
QHttpMultiPart* dataMultiPart = NULL,
|
||||||
const QVariantMap& propertyMap = QVariantMap());
|
const QVariantMap& propertyMap = QVariantMap());
|
||||||
|
|
||||||
void setIsAgent(bool isAgent);
|
void setIsAgent(bool isAgent) { _isAgent = isAgent; }
|
||||||
|
|
||||||
const QUrl& getAuthURL() const { return _authURL; }
|
const QUrl& getAuthURL() const { return _authURL; }
|
||||||
void setAuthURL(const QUrl& authURL);
|
void setAuthURL(const QUrl& authURL);
|
||||||
|
@ -121,6 +121,7 @@ private:
|
||||||
void passErrorToCallback(QNetworkReply* reply);
|
void passErrorToCallback(QNetworkReply* reply);
|
||||||
|
|
||||||
QUrl _authURL;
|
QUrl _authURL;
|
||||||
|
|
||||||
QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap;
|
QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap;
|
||||||
|
|
||||||
DataServerAccountInfo _accountInfo;
|
DataServerAccountInfo _accountInfo;
|
||||||
|
|
|
@ -92,6 +92,8 @@ void DomainHandler::softReset() {
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|
||||||
clearSettings();
|
clearSettings();
|
||||||
|
|
||||||
|
_connectionDenialsSinceKeypairRegen = 0;
|
||||||
|
|
||||||
// cancel the failure timeout for any pending requests for settings
|
// cancel the failure timeout for any pending requests for settings
|
||||||
QMetaObject::invokeMethod(&_settingsTimer, "stop");
|
QMetaObject::invokeMethod(&_settingsTimer, "stop");
|
||||||
|
@ -105,6 +107,7 @@ void DomainHandler::hardReset() {
|
||||||
_iceServerSockAddr = HifiSockAddr();
|
_iceServerSockAddr = HifiSockAddr();
|
||||||
_hostname = QString();
|
_hostname = QString();
|
||||||
_sockAddr.clear();
|
_sockAddr.clear();
|
||||||
|
_hasCheckedForAccessToken = false;
|
||||||
|
|
||||||
// clear any pending path we may have wanted to ask the previous DS about
|
// clear any pending path we may have wanted to ask the previous DS about
|
||||||
_pendingPath.clear();
|
_pendingPath.clear();
|
||||||
|
@ -347,3 +350,35 @@ void DomainHandler::processICEResponsePacket(QSharedPointer<ReceivedMessage> mes
|
||||||
emit icePeerSocketsReceived();
|
emit icePeerSocketsReceived();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message) {
|
||||||
|
// Read deny reason from packet
|
||||||
|
quint16 reasonSize;
|
||||||
|
message->readPrimitive(&reasonSize);
|
||||||
|
QString reason = QString::fromUtf8(message->readWithoutCopy(reasonSize));
|
||||||
|
|
||||||
|
// output to the log so the user knows they got a denied connection request
|
||||||
|
// and check and signal for an access token so that we can make sure they are logged in
|
||||||
|
qCWarning(networking) << "The domain-server denied a connection request: " << reason;
|
||||||
|
qCWarning(networking) << "Make sure you are logged in.";
|
||||||
|
|
||||||
|
if (!_domainConnectionRefusals.contains(reason)) {
|
||||||
|
_domainConnectionRefusals.append(reason);
|
||||||
|
emit domainConnectionRefused(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& accountManager = AccountManager::getInstance();
|
||||||
|
|
||||||
|
if (_hasCheckedForAccessToken) {
|
||||||
|
accountManager.checkAndSignalForAccessToken();
|
||||||
|
_hasCheckedForAccessToken = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int CONNECTION_DENIALS_FOR_KEYPAIR_REGEN = 3;
|
||||||
|
|
||||||
|
// force a re-generation of key-pair after CONNECTION_DENIALS_FOR_KEYPAIR_REGEN failed connection attempts
|
||||||
|
if (++_connectionDenialsSinceKeypairRegen >= CONNECTION_DENIALS_FOR_KEYPAIR_REGEN) {
|
||||||
|
accountManager.generateNewUserKeypair();
|
||||||
|
_connectionDenialsSinceKeypairRegen = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ public slots:
|
||||||
void processICEPingReplyPacket(QSharedPointer<ReceivedMessage> message);
|
void processICEPingReplyPacket(QSharedPointer<ReceivedMessage> message);
|
||||||
void processDTLSRequirementPacket(QSharedPointer<ReceivedMessage> dtlsRequirementPacket);
|
void processDTLSRequirementPacket(QSharedPointer<ReceivedMessage> dtlsRequirementPacket);
|
||||||
void processICEResponsePacket(QSharedPointer<ReceivedMessage> icePacket);
|
void processICEResponsePacket(QSharedPointer<ReceivedMessage> icePacket);
|
||||||
|
void processDomainServerConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void completedHostnameLookup(const QHostInfo& hostInfo);
|
void completedHostnameLookup(const QHostInfo& hostInfo);
|
||||||
|
@ -113,6 +114,8 @@ signals:
|
||||||
void settingsReceived(const QJsonObject& domainSettingsObject);
|
void settingsReceived(const QJsonObject& domainSettingsObject);
|
||||||
void settingsReceiveFail();
|
void settingsReceiveFail();
|
||||||
|
|
||||||
|
void domainConnectionRefused(QString reason);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendDisconnectPacket();
|
void sendDisconnectPacket();
|
||||||
void hardReset();
|
void hardReset();
|
||||||
|
@ -130,6 +133,10 @@ private:
|
||||||
QJsonObject _settingsObject;
|
QJsonObject _settingsObject;
|
||||||
QString _pendingPath;
|
QString _pendingPath;
|
||||||
QTimer _settingsTimer;
|
QTimer _settingsTimer;
|
||||||
|
|
||||||
|
QStringList _domainConnectionRefusals;
|
||||||
|
bool _hasCheckedForAccessToken { false };
|
||||||
|
int _connectionDenialsSinceKeypairRegen { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DomainHandler_h
|
#endif // hifi_DomainHandler_h
|
||||||
|
|
|
@ -80,11 +80,16 @@ NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned
|
||||||
// send a ping punch immediately
|
// send a ping punch immediately
|
||||||
connect(&_domainHandler, &DomainHandler::icePeerSocketsReceived, this, &NodeList::pingPunchForDomainServer);
|
connect(&_domainHandler, &DomainHandler::icePeerSocketsReceived, this, &NodeList::pingPunchForDomainServer);
|
||||||
|
|
||||||
|
auto &accountManager = AccountManager::getInstance();
|
||||||
|
|
||||||
|
// assume that we may need to send a new DS check in anytime a new keypair is generated
|
||||||
|
connect(&accountManager, &AccountManager::newKeypair, this, &NodeList::sendDomainServerCheckIn);
|
||||||
|
|
||||||
// clear out NodeList when login is finished
|
// clear out NodeList when login is finished
|
||||||
connect(&AccountManager::getInstance(), &AccountManager::loginComplete , this, &NodeList::reset);
|
connect(&accountManager, &AccountManager::loginComplete , this, &NodeList::reset);
|
||||||
|
|
||||||
// clear our NodeList when logout is requested
|
// clear our NodeList when logout is requested
|
||||||
connect(&AccountManager::getInstance(), &AccountManager::logoutComplete , this, &NodeList::reset);
|
connect(&accountManager, &AccountManager::logoutComplete , this, &NodeList::reset);
|
||||||
|
|
||||||
// anytime we get a new node we will want to attempt to punch to it
|
// anytime we get a new node we will want to attempt to punch to it
|
||||||
connect(this, &LimitedNodeList::nodeAdded, this, &NodeList::startNodeHolePunch);
|
connect(this, &LimitedNodeList::nodeAdded, this, &NodeList::startNodeHolePunch);
|
||||||
|
@ -281,8 +286,6 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
<< "but no keypair is present. Waiting for keypair generation to complete.";
|
<< "but no keypair is present. Waiting for keypair generation to complete.";
|
||||||
accountManager.generateNewUserKeypair();
|
accountManager.generateNewUserKeypair();
|
||||||
|
|
||||||
connect(&accountManager, &AccountManager::newKeypair, this, &NodeList::sendDomainServerCheckIn);
|
|
||||||
|
|
||||||
// don't send the check in packet - wait for the keypair first
|
// don't send the check in packet - wait for the keypair first
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue