From ec18199c086f0f7eb6717de2ba40e82dfbdb663d Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 27 Jan 2025 02:45:04 -0500 Subject: [PATCH] ResolvePeer method now checks if the caller is a host and the request contains a IdentifyAs header --- src/Socialbox/Classes/StandardMethods/ResolvePeer.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Socialbox/Classes/StandardMethods/ResolvePeer.php b/src/Socialbox/Classes/StandardMethods/ResolvePeer.php index 0cdc6bf..f2be123 100644 --- a/src/Socialbox/Classes/StandardMethods/ResolvePeer.php +++ b/src/Socialbox/Classes/StandardMethods/ResolvePeer.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Socialbox\Abstracts\Method; use Socialbox\Classes\Configuration; + use Socialbox\Enums\ReservedUsernames; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\RpcException; @@ -41,10 +42,17 @@ throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); } + // Check if host is making the request & the identifier is not empty + $identifyAs = null; + if($request->getPeer()->getUsername() == ReservedUsernames::HOST && $request->getIdentifyAs() != null) + { + $identifyAs = $request->getIdentifyAs(); + } + // Resolve the peer using the server's peer resolver, this will resolve both internal peers and external peers try { - return $rpcRequest->produceResponse(Socialbox::resolvePeer($peerAddress)); + return $rpcRequest->produceResponse(Socialbox::resolvePeer($peerAddress, $identifyAs)); } catch(Exception $e) {