Made message signing in Cryptography use SHA512 as the message content for... #1
4 changed files with 59 additions and 7 deletions
46
src/Socialbox/Classes/CliCommands/DnsRecordCommand.php
Normal file
46
src/Socialbox/Classes/CliCommands/DnsRecordCommand.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Classes\CliCommands;
|
||||
|
||||
use Socialbox\Classes\Configuration;
|
||||
use Socialbox\Classes\Logger;
|
||||
use Socialbox\Interfaces\CliCommandInterface;
|
||||
|
||||
class DnsRecordCommand implements CliCommandInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(array $args): int
|
||||
{
|
||||
$txt_record = sprintf('v=socialbox;sb-rpc=%s;sb-key=%s',
|
||||
Configuration::getInstanceConfiguration()->getRpcEndpoint(),
|
||||
Configuration::getInstanceConfiguration()->getPublicKey()
|
||||
);
|
||||
|
||||
Logger::getLogger()->info('Please set the following DNS TXT record for the domain:');
|
||||
Logger::getLogger()->info(sprintf(' %s', $txt_record));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getHelpMessage(): string
|
||||
{
|
||||
return <<<HELP
|
||||
Usage: socialbox dns-record
|
||||
|
||||
Displays the DNS TXT record that should be set for the domain.
|
||||
HELP;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getShortHelpMessage(): string
|
||||
{
|
||||
return 'Displays the DNS TXT record that should be set for the domain.';
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
namespace Socialbox\Classes;
|
||||
|
||||
use LogLib\Log;
|
||||
use function Symfony\Component\String\s;
|
||||
|
||||
class Logger
|
||||
{
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace Socialbox\Enums;
|
||||
|
||||
use Socialbox\Classes\CliCommands\HelpCommand;
|
||||
use Socialbox\Classes\CliCommands\DnsRecordCommand;
|
||||
use Socialbox\Classes\CliCommands\InitializeCommand;
|
||||
|
||||
enum CliCommands : string
|
||||
{
|
||||
case INITIALIZE = 'init';
|
||||
case CLIENT = 'client';
|
||||
case DNS_RECORD = 'dns-record';
|
||||
|
||||
/**
|
||||
* Handles the command execution, returns the exit code.
|
||||
|
@ -21,14 +21,15 @@ enum CliCommands : string
|
|||
return match ($this)
|
||||
{
|
||||
self::INITIALIZE => InitializeCommand::execute($args),
|
||||
self::CLIENT => ClientCommand::execute($args)
|
||||
self::DNS_RECORD => DnsRecordCommand::execute($args)
|
||||
};
|
||||
}
|
||||
public function getHelpMessage(): string
|
||||
{
|
||||
return match ($this)
|
||||
{
|
||||
self::INITIALIZE => InitializeCommand::getHelpMessage()
|
||||
self::INITIALIZE => InitializeCommand::getHelpMessage(),
|
||||
self::DNS_RECORD => DnsRecordCommand::getHelpMessage()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,8 @@ enum CliCommands : string
|
|||
{
|
||||
return match ($this)
|
||||
{
|
||||
self::INITIALIZE => InitializeCommand::getShortHelpMessage()
|
||||
self::INITIALIZE => InitializeCommand::getShortHelpMessage(),
|
||||
self::DNS_RECORD => DnsRecordCommand::getShortHelpMessage()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
return 0;
|
||||
}
|
||||
|
||||
print($command->getHelpMessage());
|
||||
print($command->getHelpMessage() . "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,11 @@
|
|||
return CliCommands::INITIALIZE->handle($args);
|
||||
}
|
||||
|
||||
if(isset($args[CliCommands::DNS_RECORD->value]))
|
||||
{
|
||||
return CliCommands::DNS_RECORD->handle($args);
|
||||
}
|
||||
|
||||
return self::displayHelp();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue