예제 #1
0
 public function handle(Command $command, ClientContext $context) : Generator
 {
     yield from $context->writeResponse(new Response(101, 'Capability list follows (multi-line)'));
     // Generate the list of capabilities that we support.
     $capabilities = ['VERSION 2', 'READER', 'POST', 'NEWNEWS', 'LIST ACTIVE', 'IMPLEMENTATION coderstephen/nntp server'];
     // If TLS is not already active, the STARTTLS is available.
     if (!$context->getSocket()->isCryptoEnabled()) {
         //array_splice($capabilities, -2, 0, ['STARTTLS']);
     }
     $data = implode("\r\n", $capabilities);
     yield from $context->writeData($data);
 }
예제 #2
0
 public function handle(Command $command, ClientContext $context) : Generator
 {
     yield from $context->writeResponse(new Response(215, 'List of newsgroups follows'));
     $groups = (yield from $context->getAccessLayer()->getGroups());
     $data = array_reduce($groups, function (string $s, Group $group) {
         switch ($group->status()) {
             case Group::POSTING_PERMITTED:
                 $status = 'y';
                 break;
             case Group::POSTING_NOT_PERMITTED:
                 $status = 'n';
                 break;
             case Group::POSTING_FORWARDED:
                 $status = 'm';
                 break;
             default:
                 $status = 'u';
                 break;
         }
         return $s . sprintf("%s %d %d %s\r\n", $group->name(), $group->highWaterMark(), $group->lowWaterMark(), $status);
     }, '');
     yield from $context->writeData($data);
 }
예제 #3
0
 public function handle(Command $command, ClientContext $context) : Generator
 {
     yield from $context->writeResponse(new Response(100, 'Help text follows (multi-line)'));
     $data = implode("\r\n", ['article [message-id|number]', 'body [message-id|number]', 'capabilities', 'date', 'group group', 'head [message-id|number]', 'help', 'last', 'list active', 'listgroup', 'newgroups', 'newnews', 'next', 'post', 'quit', 'stat']);
     yield from $context->writeData($data);
 }