Ejemplo n.º 1
0
 public function sendAsReact($data)
 {
     $loop = \React\EventLoop\Factory::create();
     $tcpConnector = new \React\SocketClient\TcpConnector($loop);
     $tcpConnector->create('127.0.0.1', 4001)->then(function (\React\Stream\Stream $stream) use($data) {
         $stream->write($data);
         $stream->end();
     });
     $loop->run();
 }
Ejemplo n.º 2
0
             }
             $cd = new \Modl\ConfigDAO();
             $config = $cd->get();
             $port = 5222;
             $dns = \Moxl\Utils::resolveHost($msg->host);
             if (isset($dns->target) && $dns->target != null) {
                 $msg->host = $dns->target;
             }
             if (isset($dns->port) && $dns->port != null) {
                 $port = $dns->port;
             }
             #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
             $ip = \Moxl\Utils::resolveIp($msg->host);
             $ip = !$ip || !isset($ip->address) ? gethostbyname($msg->host) : $ip->address;
             fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " : " . colorize('Connection to ' . $msg->host . ' (' . $ip . ')', 'blue') . "\n");
             $connector->create($ip, $port)->then($xmpp_behaviour);
             break;
     }
 } else {
     return;
 }
 $rpc = new \RPC();
 $rpc->handle_json($msg);
 $msg = \RPC::commit();
 \RPC::clear();
 if (!empty($msg)) {
     echo base64_encode(gzcompress(json_encode($msg), 9)) . "";
     //fwrite(STDERR, colorize(json_encode($msg), 'yellow')." : ".colorize('sent to the browser', 'green')."\n");
 }
 $xml = \Moxl\API::commit();
 \Moxl\API::clear();
Ejemplo n.º 3
0
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$tcpConnector = new React\SocketClient\TcpConnector($loop);
$tcpConnector->create('10.6.1.119', 1337)->then(function (React\Stream\Stream $stream) {
    $facility = array('LOG_AUTH', 'LOG_AUTHPRIV', 'LOG_CRON', 'LOG_DAEMON', 'LOG_LOCAL0', 'LOG_LOCAL1');
    $severity = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR', 'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG');
    $programs = array('anacron', 'CRON', 'dhclient', 'kernel', 'laptop-mode', 'mtp-probe', 'NetworkManager', 'ntpd', 'rsyslogd');
    while (1) {
        $delay = usleep(200000);
        $host = 'srv-' . sprintf('%02d', rand(0, 9));
        $timestamp = time();
        $loc_severity = $severity[rand(0, count($severity) - 1)];
        $loc_facility = $facility[rand(0, count($facility) - 1)];
        $loc_progname = $programs[rand(0, count($programs) - 1)];
        $tag = $loc_progname . sprintf("[%d]", rand(12000, 64000));
        $message = "";
        for ($i = 1; $i < rand(20, 50); $i++) {
            $message .= chr(rand(97, 122));
        }
        $text = "{";
        $text .= "rows: 0,";
        $text .= "timestamp: " . $timestamp . ",";
        $text .= "received: " . $timestamp . ",";
        $text .= "message: \"" . $message . "\",";
        $text .= "host: \"" . $host . "\",";
        $text .= "severity: \"" . $loc_severity . "\",";
        $text .= "facility: \"" . $loc_facility . "\",";
        $text .= "programname: \"" . $loc_progname . "\",";
        $text .= "tag: \"" . $tag . "\"";