Fix peer identification logic in Socialbox and enhance remote resolution handling
Some checks are pending
CI / check-phpdoc (push) Waiting to run
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
Some checks are pending
CI / check-phpdoc (push) Waiting to run
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
This commit is contained in:
parent
3250407f2b
commit
03a4fa2a84
1 changed files with 21 additions and 2 deletions
|
@ -539,7 +539,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// First check if the client is identifying as the host
|
// First check if the client is identifying as the host
|
||||||
elseif($hostPeer->getAddress() !== ReservedUsernames::HOST->value)
|
elseif($hostPeer->getUsername() !== ReservedUsernames::HOST->value)
|
||||||
{
|
{
|
||||||
self::returnError(403, StandardError::FORBIDDEN, 'Cannot identify as a peer when not identifying as the host');
|
self::returnError(403, StandardError::FORBIDDEN, 'Cannot identify as a peer when not identifying as the host');
|
||||||
return;
|
return;
|
||||||
|
@ -1017,6 +1017,25 @@
|
||||||
|
|
||||||
Logger::getLogger()->debug(sprintf('Resolving external peer by %s while identified as %s', $peerAddress, $identifiedAs ?? 'nobody'));
|
Logger::getLogger()->debug(sprintf('Resolving external peer by %s while identified as %s', $peerAddress, $identifiedAs ?? 'nobody'));
|
||||||
|
|
||||||
|
// Always resolve remotely if an identifier has been provided (this is a personal resolution)
|
||||||
|
// Otherwise, in all other cases we try to use local peers first and fall back on remote if necessary
|
||||||
|
// and use local storage to improve performance when possible
|
||||||
|
if($identifiedAs !== null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return self::getExternalSession($peerAddress->getDomain())->resolvePeer($peerAddress, $identifiedAs);
|
||||||
|
}
|
||||||
|
catch(RpcException $e)
|
||||||
|
{
|
||||||
|
throw StandardRpcException::fromRpcException($e);
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve the peer from the local database if it exists
|
// Resolve the peer from the local database if it exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1098,9 +1117,9 @@
|
||||||
return $peer;
|
return $peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the peer exists and is up to date, return it from our local database instead. (Quicker)
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// If the peer exists and is up to date, return it from our local database instead. (Quicker)
|
||||||
Logger::getLogger()->debug(sprintf('Local peer resolution occurred, resolving locally stored information fields for %s', $existingPeer->getAddress()));
|
Logger::getLogger()->debug(sprintf('Local peer resolution occurred, resolving locally stored information fields for %s', $existingPeer->getAddress()));
|
||||||
$informationFields = PeerInformationManager::getFields($existingPeer);
|
$informationFields = PeerInformationManager::getFields($existingPeer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue