ResolvePeer method now checks if the caller is a host and the request contains a IdentifyAs header
This commit is contained in:
parent
c3f6f6096e
commit
ec18199c08
1 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Socialbox\Abstracts\Method;
|
use Socialbox\Abstracts\Method;
|
||||||
use Socialbox\Classes\Configuration;
|
use Socialbox\Classes\Configuration;
|
||||||
|
use Socialbox\Enums\ReservedUsernames;
|
||||||
use Socialbox\Enums\StandardError;
|
use Socialbox\Enums\StandardError;
|
||||||
use Socialbox\Exceptions\DatabaseOperationException;
|
use Socialbox\Exceptions\DatabaseOperationException;
|
||||||
use Socialbox\Exceptions\RpcException;
|
use Socialbox\Exceptions\RpcException;
|
||||||
|
@ -41,10 +42,17 @@
|
||||||
throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
|
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
|
// Resolve the peer using the server's peer resolver, this will resolve both internal peers and external peers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceResponse(Socialbox::resolvePeer($peerAddress));
|
return $rpcRequest->produceResponse(Socialbox::resolvePeer($peerAddress, $identifyAs));
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue