Made message signing in Cryptography use SHA512 as the message content for... #1
2 changed files with 17 additions and 10 deletions
|
@ -331,35 +331,33 @@ class RegisteredPeerManager
|
||||||
/**
|
/**
|
||||||
* Removes a specific flag from the peer identified by the given UUID or RegisteredPeerRecord.
|
* Removes a specific flag from the peer identified by the given UUID or RegisteredPeerRecord.
|
||||||
*
|
*
|
||||||
* @param string|RegisteredPeerRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer.
|
* @param string|RegisteredPeerRecord $peer
|
||||||
* @param PeerFlags $flag The flag to be removed from the peer.
|
* @param PeerFlags $flag The flag to be removed from the peer.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DatabaseOperationException If there is an error while updating the database.
|
* @throws DatabaseOperationException If there is an error while updating the database.
|
||||||
*/
|
*/
|
||||||
public static function removeFlag(string|RegisteredPeerRecord $uuid, PeerFlags $flag): void
|
public static function removeFlag(string|RegisteredPeerRecord $peer, PeerFlags $flag): void
|
||||||
{
|
{
|
||||||
if($uuid instanceof RegisteredPeerRecord)
|
if(is_string($peer))
|
||||||
{
|
{
|
||||||
$uuid = $uuid->getUuid();
|
$peer = self::getPeer($peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::getLogger()->verbose(sprintf("Removing flag %s from peer %s", $flag->value, $uuid));
|
Logger::getLogger()->verbose(sprintf("Removing flag %s from peer %s", $flag->value, $peer->getUuid()));
|
||||||
|
|
||||||
$peer = self::getPeer($uuid);
|
|
||||||
if(!$peer->flagExists($flag))
|
if(!$peer->flagExists($flag))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$flags = $peer->getFlags();
|
$peer->removeFlag($flag);
|
||||||
unset($flags[array_search($flag, $flags)]);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$implodedFlags = implode(',', $flags);
|
$implodedFlags = PeerFlags::toString($peer->getFlags());
|
||||||
$statement = Database::getConnection()->prepare('UPDATE `registered_peers` SET flags=? WHERE uuid=?');
|
$statement = Database::getConnection()->prepare('UPDATE `registered_peers` SET flags=? WHERE uuid=?');
|
||||||
$statement->bindParam(1, $implodedFlags);
|
$statement->bindParam(1, $implodedFlags);
|
||||||
$statement->bindParam(2, $uuid);
|
$statement->bindParam(2, $registeredPeer);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
}
|
}
|
||||||
catch(PDOException $e)
|
catch(PDOException $e)
|
||||||
|
|
|
@ -104,6 +104,15 @@ class RegisteredPeerRecord implements SerializableInterface
|
||||||
return in_array($flag, $this->flags, true);
|
return in_array($flag, $this->flags, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeFlag(PeerFlags $flag): void
|
||||||
|
{
|
||||||
|
$key = array_search($flag, $this->flags, true);
|
||||||
|
if($key !== false)
|
||||||
|
{
|
||||||
|
unset($this->flags[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the current instance is enabled.
|
* Checks if the current instance is enabled.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue