Exemplo n.º 1
0
 public function testMsgDbDefault()
 {
     $uuid1 = '10000000-1000-4001-8001-1000000000';
     $uuid2 = '20000000-2000-4002-8002-20000000';
     @unlink('test_data/bucket_root.yml');
     $runName = uniqid('', true);
     $prvFileName = 'testfile_cronjob_id_rsa_' . date('Ymd_His') . '_' . $runName . '.prv';
     $pubFileName = 'testfile_cronjob_id_rsa_' . date('Ymd_His') . '_' . $runName . '.pub';
     $settignsFileName = 'testfile_cronjob_settings_' . date('Ymd_His') . '_' . $runName . '.pub';
     file_put_contents('test_data/' . $prvFileName, static::NODE_LOCAL_SSL_KEY_PRV);
     file_put_contents('test_data/' . $pubFileName, static::NODE_LOCAL_SSL_KEY_PUB);
     $settings = new Settings('test_data/' . $settignsFileName);
     $settings->data['datadir'] = 'test_data';
     $settings->data['node']['id'] = Node::genIdHexStr(static::NODE_LOCAL_SSL_KEY_PUB);
     $settings->data['node']['sslKeyPrvPass'] = '******';
     $settings->data['node']['sslKeyPrvPath'] = 'test_data/' . $prvFileName;
     $settings->data['node']['sslKeyPubPath'] = 'test_data/' . $pubFileName;
     $settings->data['node']['bridge']['client']['enabled'] = false;
     #$settings->setDataChanged(true);
     #$settings->save();
     $localNode = new Node();
     $localNode->setIdHexStr($settings->data['node']['id']);
     $localNode->setUri($settings->data['node']['uriLocal']);
     $localNode->setSslKeyPub(file_get_contents($settings->data['node']['sslKeyPubPath']));
     $this->assertEquals(static::NODE_LOCAL_SSL_KEY_PUB, $localNode->getSslKeyPub());
     // @codingStandardsIgnoreStart
     #$this->assertEquals('FC_WwG2GdTmCLSKhpEmJso6pejm9c6oACjX', Node::genSslKeyFingerprint($localNode->getSslKeyPub()));
     $this->assertEquals('FC_6t6Z9dYVWEDfEzGQGDSAteLQsFE8SDwZFK2PoiQuM2ezFUA2yNpBPiT9oBwvFBfzDWZzZF5sxBtcSd', Node::genSslKeyFingerprint($localNode->getSslKeyPub()));
     // @codingStandardsIgnoreEnd
     $nodes = array();
     $nodes[0] = new Node();
     $nodes[0]->setIdHexStr($uuid1 . '00');
     $nodes[0]->setUri('tcp://127.0.0.0:25000');
     $nodes[0]->setSslKeyPub(static::NODE0_SSL_KEY_PUB);
     $nodes[1] = new Node();
     $nodes[1]->setIdHexStr($uuid1 . '01');
     $nodes[1]->setUri('tcp://127.0.0.1:25000');
     $nodes[2] = new Node();
     $nodes[2]->setIdHexStr($uuid1 . '02');
     $nodes[2]->setUri('tcp://127.0.0.2:25000');
     $nodes[2]->setSslKeyPub(static::NODE2_SSL_KEY_PUB);
     $nodes[3] = new Node();
     $nodes[3]->setIdHexStr($uuid1 . '03');
     $nodes[3]->setUri('tcp://127.0.0.3:25000');
     $nodes[4] = new Node();
     $nodes[4]->setIdHexStr($uuid1 . '04');
     $nodes[4]->setUri('tcp://127.0.0.4:25000');
     $nodes[4]->setSslKeyPub(static::NODE4_SSL_KEY_PUB);
     $nodes[5] = new Node();
     $nodes[5]->setIdHexStr($uuid1 . '05');
     $nodes[5]->setUri('tcp://127.0.0.5:25000');
     $nodes[5]->setSslKeyPub(static::NODE5_SSL_KEY_PUB);
     $table = new Table();
     $table->setDatadirBasePath($settings->data['datadir']);
     $table->setLocalNode($localNode);
     $table->nodeEnclose($nodes[0]);
     $table->nodeEnclose($nodes[1]);
     $table->nodeEnclose($nodes[2]);
     #$table->nodeEnclose($nodes[3]); // Test not in table.
     #$table->nodeEnclose($nodes[4]);
     #$table->nodeEnclose($nodes[5]);
     $msgs = array();
     for ($nodeNo = 1000; $nodeNo <= 1011; $nodeNo++) {
         $msg = new Msg();
         $msg->setId($uuid2 . $nodeNo);
         $this->assertEquals($uuid2 . $nodeNo, $msg->getId());
         $msg->setSrcNodeId($settings->data['node']['id']);
         $msg->setSrcSslKeyPub($table->getLocalNode()->getSslKeyPub());
         $msg->setSrcUserNickname($settings->data['user']['nickname']);
         $msg->setText('this is  a test. ' . date('Y-m-d H:i:s'));
         $msg->setSslKeyPrvPath($settings->data['node']['sslKeyPrvPath'], $settings->data['node']['sslKeyPrvPass']);
         $msg->setStatus('O');
         $msg->setDstNodeId($nodes[0]->getIdHexStr());
         $msg->setEncryptionMode('D');
         $msg->setDstSslPubKey($nodes[0]->getSslKeyPub());
         $msgs[$nodeNo] = $msg;
         #fwrite(STDOUT, __METHOD__.' msg setup: '.$nodeNo.''.PHP_EOL);
     }
     $msgs[1001]->setDstNodeId($nodes[1]->getIdHexStr());
     $msgs[1001]->setEncryptionMode('S');
     $msgs[1001]->setDstSslPubKey($table->getLocalNode()->getSslKeyPub());
     $this->assertEquals('S', $msgs[1001]->getEncryptionMode());
     $msgs[1002]->setDstNodeId($nodes[2]->getIdHexStr());
     $msgs[1002]->setEncryptionMode('S');
     $msgs[1002]->setDstSslPubKey($table->getLocalNode()->getSslKeyPub());
     $this->assertEquals('S', $msgs[1002]->getEncryptionMode());
     $msgs[1003]->setDstNodeId($nodes[3]->getIdHexStr());
     $msgs[1003]->setEncryptionMode('S');
     $msgs[1003]->setDstSslPubKey($table->getLocalNode()->getSslKeyPub());
     $this->assertEquals('S', $msgs[1003]->getEncryptionMode());
     $msgs[1004]->setSentNodes(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
     $this->assertEquals(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), $msgs[1004]->getSentNodes());
     $msgs[1005]->setStatus('U');
     $msgs[1006]->setStatus('S');
     $msgs[1007]->setStatus('S');
     $msgs[1007]->setSentNodes(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21));
     $msgs[1008]->setStatus('S');
     $msgs[1008]->setForwardCycles(110);
     $msgs[1008]->setSentNodes(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
     $msgs[1009]->setStatus('S');
     $msgs[1009]->setSentNodes(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, $uuid1 . '00'));
     $msgs[1010]->setRelayNodeId($uuid1 . '01');
     $msgs[1011]->setSrcNodeId($nodes[4]->getIdHexStr());
     $msgs[1011]->setDstNodeId($nodes[5]->getIdHexStr());
     $msgs[1011]->setStatus('U');
     $msgDb = new MsgDb();
     $msgDb->setDatadirBasePath($settings->data['datadir']);
     $cronjobLog = new Logger('cronjob');
     #$cronjobLog->pushHandler(new LoggerStreamHandler('php://stdout', Logger::DEBUG));
     $cronjob = new Cronjob();
     $cronjob->setLog($cronjobLog);
     $cronjob->setMsgDb($msgDb);
     $cronjob->setSettings($settings);
     $cronjob->setTable($table);
     // Encrypt
     foreach ($msgs as $msgId => $msg) {
         #fwrite(STDOUT, __METHOD__.' encrypt: '.$msgId.PHP_EOL);
         $encrypted = false;
         try {
             $encrypted = $msg->encrypt();
         } catch (Exception $e) {
             print 'ERROR: ' . $e->getMessage() . PHP_EOL;
         }
         $this->assertTrue($encrypted);
         $rv = $cronjob->getMsgDb()->msgAdd($msg);
     }
     $this->assertEquals(12, $cronjob->getMsgDb()->getMsgsCount());
     // Init Nodes
     #fwrite(STDOUT, __METHOD__.' init nodes'.PHP_EOL);
     $cronjob->msgDbInitNodes();
     $cronjobMsgs = $cronjob->getMsgDb()->getMsgs();
     #foreach($cronjobMsgs as $msgId => $msg){
     #	$logOut = $msg->getId().', '.$msg->getStatus().', '.$msg->getEncryptionMode();
     #	fwrite(STDOUT, __METHOD__.' cronjobMsgs: '.$logOut.PHP_EOL);
     #}
     $this->assertEquals(12, count($cronjobMsgs));
     $this->assertEquals($msgs[1000], $cronjobMsgs[$uuid2 . '1000']);
     $this->assertEquals($msgs[1001], $cronjobMsgs[$uuid2 . '1001']);
     $this->assertEquals($msgs[1002], $cronjobMsgs[$uuid2 . '1002']);
     $this->assertEquals($msgs[1003], $cronjobMsgs[$uuid2 . '1003']);
     $this->assertEquals($msgs[1004], $cronjobMsgs[$uuid2 . '1004']);
     $this->assertEquals($msgs[1005], $cronjobMsgs[$uuid2 . '1005']);
     $this->assertEquals($msgs[1006], $cronjobMsgs[$uuid2 . '1006']);
     $this->assertEquals($msgs[1007], $cronjobMsgs[$uuid2 . '1007']);
     $this->assertEquals($msgs[1008], $cronjobMsgs[$uuid2 . '1008']);
     $this->assertEquals($msgs[1009], $cronjobMsgs[$uuid2 . '1009']);
     $this->assertEquals($msgs[1010], $cronjobMsgs[$uuid2 . '1010']);
     $this->assertEquals($msgs[1011], $cronjobMsgs[$uuid2 . '1011']);
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1000']->getEncryptionMode());
     $this->assertEquals('S', $cronjobMsgs[$uuid2 . '1001']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1002']->getEncryptionMode());
     $this->assertEquals('S', $cronjobMsgs[$uuid2 . '1003']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1004']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1005']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1006']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1007']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1008']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1009']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1010']->getEncryptionMode());
     $this->assertEquals('D', $cronjobMsgs[$uuid2 . '1011']->getEncryptionMode());
     $updateMsgs = $cronjob->msgDbSendAll();
     /*foreach($updateMsgs as $msgId => $msg){
     			$logOut = '/'.$msg['obj']->getId().'/';
     			$logOut .= ' /'.$msg['obj']->getStatus().'/';
     			$logOut .= ' /'.$msg['obj']->getEncryptionMode().'/'.' '.count($msg['nodes']);
     			fwrite(STDOUT, __METHOD__.' update msg: '.$logOut.PHP_EOL);
     			#ve($msg['nodes']);
     		}*/
     $this->assertEquals(6, count($updateMsgs));
     $this->assertEquals('O', $msgs[1000]->getStatus());
     $this->assertEquals('O', $msgs[1002]->getStatus());
     $this->assertEquals('U', $msgs[1005]->getStatus());
     $this->assertEquals('S', $msgs[1006]->getStatus());
     $this->assertEquals('O', $msgs[1010]->getStatus());
     $this->assertEquals('U', $msgs[1011]->getStatus());
     $this->assertEquals('D', $msgs[1000]->getEncryptionMode());
     $this->assertEquals('D', $msgs[1002]->getEncryptionMode());
     $this->assertEquals('D', $msgs[1005]->getEncryptionMode());
     $this->assertEquals('D', $msgs[1006]->getEncryptionMode());
     $this->assertEquals('D', $msgs[1010]->getEncryptionMode());
     $this->assertEquals('D', $msgs[1011]->getEncryptionMode());
     $this->assertTrue(array_key_exists($uuid2 . '1000', $updateMsgs));
     $this->assertTrue(array_key_exists($uuid2 . '1002', $updateMsgs));
     $this->assertTrue(array_key_exists($uuid2 . '1005', $updateMsgs));
     $this->assertTrue(array_key_exists($uuid2 . '1006', $updateMsgs));
     $this->assertTrue(array_key_exists($uuid2 . '1010', $updateMsgs));
     $this->assertTrue(array_key_exists($uuid2 . '1011', $updateMsgs));
     $this->assertEquals(3, count($updateMsgs[$uuid2 . '1000']['nodes']));
     $this->assertEquals(3, count($updateMsgs[$uuid2 . '1002']['nodes']));
     $this->assertEquals(3, count($updateMsgs[$uuid2 . '1005']['nodes']));
     $this->assertEquals(3, count($updateMsgs[$uuid2 . '1006']['nodes']));
     $this->assertEquals(2, count($updateMsgs[$uuid2 . '1010']['nodes']));
     $this->assertEquals(3, count($updateMsgs[$uuid2 . '1011']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '00', $updateMsgs[$uuid2 . '1000']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '01', $updateMsgs[$uuid2 . '1000']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '02', $updateMsgs[$uuid2 . '1000']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '00', $updateMsgs[$uuid2 . '1002']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '01', $updateMsgs[$uuid2 . '1002']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '02', $updateMsgs[$uuid2 . '1002']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '00', $updateMsgs[$uuid2 . '1005']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '01', $updateMsgs[$uuid2 . '1005']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '02', $updateMsgs[$uuid2 . '1005']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '00', $updateMsgs[$uuid2 . '1006']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '01', $updateMsgs[$uuid2 . '1006']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '02', $updateMsgs[$uuid2 . '1006']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '00', $updateMsgs[$uuid2 . '1010']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '02', $updateMsgs[$uuid2 . '1010']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '00', $updateMsgs[$uuid2 . '1011']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '01', $updateMsgs[$uuid2 . '1011']['nodes']));
     $this->assertTrue(array_key_exists($uuid1 . '02', $updateMsgs[$uuid2 . '1011']['nodes']));
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     #$this->executePre($input, $output);
     #$bytesizeFormatter = new Binary();
     #$bytesize = new ByteSize($bytesizeFormatter);
     $bytesize = new ByteSize();
     if ($input->hasOption('name') && $input->getOption('name')) {
         print PhpChat::NAME;
     } elseif ($input->hasOption('name_lc') && $input->getOption('name_lc')) {
         print strtolower(PhpChat::NAME);
     } elseif ($input->hasOption('version_number') && $input->getOption('version_number')) {
         print PhpChat::VERSION;
     } elseif ($input->hasOption('connections') && $input->getOption('connections')) {
         print 'Live Connections' . PHP_EOL . PHP_EOL;
         $this->executePre($input, $output);
         $this->log = new Logger($this->getName());
         #$this->log->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
         $this->log->pushHandler(new StreamHandler($this->getLogfilePath(), Logger::DEBUG));
         $this->initIpcKernelConnection();
         $color = new Color();
         $startTime = time();
         $time = time();
         $seconds = 0;
         $oldClients = array();
         $clientsIdMax = 0;
         $tcols = (int) exec('tput cols');
         $tlines = (int) exec('tput lines');
         #print 'cols: '.$tcols.PHP_EOL;
         #print 'lines: '.$tlines.PHP_EOL;
         $baseLines = 5;
         print ' Traffic IN:  N/A' . PHP_EOL;
         print ' Traffic OUT: N/A' . PHP_EOL;
         #print ' Traffic AVG: N/A'.PHP_EOL;
         print ' Clients: N/A' . PHP_EOL;
         #sleep(1);
         #print '---A'.PHP_EOL;
         print '' . PHP_EOL;
         #sleep(1);
         #print '---B'.PHP_EOL;
         print ' ' . PHP_EOL;
         #sleep(1);
         Console::cursorJumpToColumn(1);
         #sleep(1);
         Console::cursorUp($baseLines);
         #sleep(1);
         while (!$this->getExit()) {
             #$this->log->debug('run');
             if (!$this->ipcKernelConnection->run()) {
                 $this->log->info('Connection to kernel process end unexpected.');
                 $this->setExit(1);
             }
             $update = false;
             if ($time != time()) {
                 $time = time();
                 $seconds++;
                 $tcols = (int) exec('tput cols');
                 $tlines = (int) exec('tput lines');
                 $update = true;
             }
             $update = true;
             if ($update) {
                 $clientsInfo = $this->ipcKernelConnection->execSync('serverClientsInfo');
                 $clientsId = $clientsInfo['clientsId'];
                 $clientsChanged = 0;
                 foreach ($clientsInfo['clients'] as $newClientId => $newClient) {
                     if (isset($oldClients[$newClientId])) {
                         $oldClient = $oldClients[$newClientId];
                         $changed = false;
                         foreach (static::$CONNECTION_INFO_FIELDS as $fieldName) {
                             if ($oldClient[$fieldName] != $newClient[$fieldName]) {
                                 $this->log->debug('update ' . $newClientId . ': ' . $fieldName . '=' . (int) $newClient[$fieldName]);
                                 $oldClients[$newClientId][$fieldName] = $newClient[$fieldName];
                                 $oldClients[$newClientId]['lastUpdate'] = time();
                             }
                         }
                         if ($changed) {
                             $clientsChanged++;
                         }
                     } else {
                         $this->log->debug('new client: ' . $newClientId);
                         $oldClients[$newClientId] = array('lastUpdate' => time(), 'hasId' => $newClient['hasId'], 'hasTalkRequest' => $newClient['hasTalkRequest'], 'hasTalk' => $newClient['hasTalk'], 'hasTalkClose' => $newClient['hasTalkClose'], 'hasShutdown' => $newClient['hasShutdown'], 'isChannelPeer' => $newClient['isChannelPeer'], 'isChannelLocal' => $newClient['isChannelLocal'], 'isOutbound' => $newClient['isOutbound'], 'isInbound' => $newClient['isInbound'], 'isBridgeServer' => $newClient['isBridgeServer'], 'isBridgeClient' => $newClient['isBridgeClient'], 'shutdown' => 0, 'status' => '.');
                     }
                 }
                 foreach ($oldClients as $oldClientId => $oldClient) {
                     if (!isset($clientsInfo['clients'][$oldClientId]) || $oldClient['hasShutdown']) {
                         if (!$oldClients[$oldClientId]['shutdown']) {
                             $this->log->debug('update ' . $oldClientId . ': shutdown=1');
                             $oldClients[$oldClientId]['shutdown'] = time();
                             $oldClients[$oldClientId]['lastUpdate'] = time();
                         }
                     }
                     if ($oldClient['isOutbound']) {
                         $oldClients[$oldClientId]['status'] = 'o';
                     }
                     if ($oldClient['isInbound']) {
                         $oldClients[$oldClientId]['status'] = 'i';
                     }
                     if ($oldClient['isChannelPeer'] || $oldClient['isChannelLocal']) {
                         $oldClients[$oldClientId]['status'] = 'c';
                     }
                     if ($oldClient['isBridgeServer'] || $oldClient['isBridgeClient']) {
                         $oldClients[$oldClientId]['status'] = 'b';
                     }
                     if ($oldClient['hasTalkRequest']) {
                         $oldClients[$oldClientId]['status'] = 't';
                     }
                     if ($oldClient['hasTalk']) {
                         $oldClients[$oldClientId]['status'] = 'T';
                     }
                     if ($oldClient['hasTalkClose']) {
                         $oldClients[$oldClientId]['status'] = 'X';
                     }
                     if ($oldClient['shutdown']) {
                         #$this->log->debug('client '.$oldClientId.' has shutdown: '.(time() - $oldClient['shutdown']));
                         $oldClients[$oldClientId]['status'] = 'x';
                         if ($oldClient['shutdown'] <= time() - 5) {
                             unset($oldClients[$oldClientId]);
                         }
                     }
                 }
                 $oldClientsLen = count($oldClients);
                 Console::cursorJumpToColumn(15);
                 #sleep(1);
                 print $bytesize->format($clientsInfo['traffic']['in']);
                 #sleep(1);
                 Console::lineClearRight();
                 #sleep(1);
                 print Console::cursorDown();
                 #sleep(1);
                 Console::cursorJumpToColumn(15);
                 #sleep(1);
                 print $bytesize->format($clientsInfo['traffic']['out']);
                 #sleep(1);
                 Console::lineClearRight();
                 #sleep(1);
                 print Console::cursorDown();
                 #sleep(1);
                 Console::cursorJumpToColumn(11);
                 #sleep(1);
                 print $oldClientsLen . ' / ' . $clientsId;
                 #sleep(1);
                 Console::lineClearRight();
                 #sleep(1);
                 print Console::cursorDown();
                 #sleep(1);
                 /*Console::cursorJumpToColumn(15);
                 		#sleep(1);
                 		$trafficTotal = bcadd($clientsInfo['traffic']['in'], $clientsInfo['traffic']['out']);
                 		print $bytesize->format(bcdiv($trafficTotal, time() - $clientsInfo['timeCreated'])).'/s';
                 		#print time() - $clientsInfo['timeCreated'];
                 		#sleep(1);
                 		Console::lineClearRight();
                 		#sleep(1);
                 		print Console::cursorDown();
                 		#sleep(1);*/
                 print Console::cursorDown();
                 #sleep(1);
                 Console::cursorJumpToColumn(2);
                 #sleep(1);
                 #print PHP_EOL.' ';
                 #sleep(1);
                 $line = 0;
                 $lineClients = 0;
                 foreach ($oldClients as $oldClientId => $oldClient) {
                     #$this->log->debug('client '.$oldClientId.' print: '.(time() - $oldClient['lastUpdate']));
                     $output = $oldClient['status'];
                     if ($oldClient['lastUpdate'] >= time() - 2) {
                         $output = $color($oldClient['status'])->bg_green;
                     } elseif ($oldClient['lastUpdate'] <= time() - 60) {
                         #$output = $color($oldClient['status'])->dark;
                         $output = $color($oldClient['status'])->bg_blue;
                     }
                     print $output;
                     $lineClients++;
                     if ($lineClients >= $tcols - 2) {
                         $lineClients = 0;
                         $line++;
                         print PHP_EOL . ' ';
                     }
                 }
                 Console::screenClearToBottom();
                 #sleep(1);
                 print PHP_EOL;
                 #sleep(1);
                 Console::cursorJumpToColumn(1);
                 #sleep(1);
                 Console::cursorUp($line + $baseLines);
                 #sleep(1);
             }
             usleep(static::LOOP_USLEEP);
         }
         #sleep(1);
         Console::cursorUp();
         #sleep(1);
         Console::screenClearToBottom();
         #sleep(1);
         $this->executePost();
         $this->log->info('exit');
     } else {
         $settings = $this->getSettings();
         $localNode = new Node();
         $localNode->setIdHexStr($settings->data['node']['id']);
         $localNode->setUri($settings->data['node']['uriLocal']);
         $localNode->setSslKeyPub(file_get_contents($settings->data['node']['sslKeyPubPath']));
         $trafficIn = $bytesize->format($settings->data['node']['traffic']['in']);
         $trafficIn .= ' (' . $settings->data['node']['traffic']['in'] . ' byte)';
         $trafficOut = $bytesize->format($settings->data['node']['traffic']['out']);
         $trafficOut .= ' (' . $settings->data['node']['traffic']['out'] . ' byte)';
         print '--------' . PHP_EOL;
         print 'Informations about local node:' . PHP_EOL;
         print '   Version: ' . PhpChat::NAME . '/' . PhpChat::VERSION . ' (release ' . PhpChat::RELEASE . ')' . PHP_EOL;
         print '   ID: ' . $localNode->getIdHexStr() . PHP_EOL;
         print '   Public key fingerprint: ' . $localNode->getSslKeyPubFingerprint() . PHP_EOL;
         print '   Last public IP: ' . $settings->data['node']['uriPub'] . PHP_EOL;
         print '   Listen IP:Port: ' . $settings->data['node']['uriLocal'] . PHP_EOL;
         print '   Traffic IN:  ' . $trafficIn . PHP_EOL;
         print '   Traffic OUT: ' . $trafficOut . PHP_EOL;
         print '   Nickname: ' . $settings->data['user']['nickname'] . PHP_EOL;
         print '   SSL version: ' . OPENSSL_VERSION_TEXT . PHP_EOL;
         print '--------' . PHP_EOL;
         print '   Pub Key Base64:' . PHP_EOL . base64_encode($localNode->getSslKeyPub()) . PHP_EOL;
         print '--------' . PHP_EOL;
     }
     #$this->executePost();
 }
Exemplo n.º 3
0
 public function testSetSslKeyPub3()
 {
     $node = new Node();
     $node->setSslKeyPub(static::SSL_KEY_PUB2_B);
     // @codingStandardsIgnoreStart
     $this->assertEquals('FC_SxXQaupNHdvtYVknJyqasrqsabsdZCwGMFrh34GiggcuF9Ry1LrWgdm9RjJeG8sd4rhgpjAvfnPaK9t', $node->getSslKeyPubFingerprint());
     // @codingStandardsIgnoreEnd
     $this->assertEquals(static::SSL_KEY_PUB2_A, $node->getSslKeyPub());
 }