diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4d678df --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +config.json +vendor/ diff --git a/Dockerfile b/Dockerfile index 70c0c20..58c22e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ FROM composer:1.6 as composer COPY . /app RUN composer install --no-interaction --no-dev --ignore-platform-reqs --optimize-autoloader -FROM alpine:3.6 -MAINTAINER Spring Signage Ltd +FROM alpine:3.11 +MAINTAINER Xibo Signage Ltd ENV XMR_DEBUG false ENV XMR_QUEUE_POLL 5 @@ -11,7 +11,14 @@ ENV XMR_QUEUE_SIZE 10 ENV XMR_IPV6RESPSUPPORT false ENV XMR_IPV6PUBSUPPORT false -RUN apk update && apk upgrade && apk add tar php7 curl php7-zmq php7-phar php7-json php7-openssl && rm -rf /var/cache/apk/* +RUN apk update && apk upgrade && apk add tar \ + php7 \ + curl \ + php7-zmq \ + php7-phar \ + php7-json \ + php7-openssl \ + && rm -rf /var/cache/apk/* EXPOSE 9505 50001 diff --git a/bin/xmr.phar b/bin/xmr.phar index d02e429..94ef8bc 100755 Binary files a/bin/xmr.phar and b/bin/xmr.phar differ diff --git a/composer.json b/composer.json index 877a332..b99b9d9 100644 --- a/composer.json +++ b/composer.json @@ -7,15 +7,15 @@ "spring signage" ], "homepage": "http://xibo.org.uk", - "license": "AGPL-3.0", + "license": "AGPL-3.0-or-later", "authors": [ { "name": "Daniel Garner", "homepage": "https://github.com/dasgarner" }, { - "name": "Spring Signage Ltd", - "homepage": "http://springsignage.com" + "name": "Xibo Signage Ltd", + "homepage": "https://xibo.org.uk" }, { "name": "Xibo Contributors", @@ -23,8 +23,14 @@ } ], "bin": ["bin/xmr.phar"], + "config": { + "platform": { + "php": "7.0.8", + "ext-zmq": "1" + } + }, "require": { - "php": ">=5.5", + "php": ">=7.0.8", "monolog/monolog": "^1.17", "react/zmq": "^0.3.0" } diff --git a/composer.lock b/composer.lock index 51bb541..3082e8e 100644 --- a/composer.lock +++ b/composer.lock @@ -1,11 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "b429a469ce918c5c513986d22dc57b36", - "content-hash": "1540b9c7592999e2be0bd170e073b2c0", + "content-hash": "36c586c66e6ad83197df56a600e31145", "packages": [ { "name": "evenement/evenement", @@ -53,20 +52,20 @@ "event-dispatcher", "event-emitter" ], - "time": "2017-07-17 17:39:19" + "time": "2017-07-17T17:39:19+00:00" }, { "name": "monolog/monolog", - "version": "1.23.0", + "version": "1.25.3", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4" + "reference": "fa82921994db851a8becaf3787a9e73c5976b6f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4", - "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fa82921994db851a8becaf3787a9e73c5976b6f1", + "reference": "fa82921994db851a8becaf3787a9e73c5976b6f1", "shasum": "" }, "require": { @@ -131,20 +130,20 @@ "logging", "psr-3" ], - "time": "2017-06-19 01:22:40" + "time": "2019-12-20T14:15:16+00:00" }, { "name": "psr/log", - "version": "1.0.2", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", "shasum": "" }, "require": { @@ -153,7 +152,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -178,7 +177,7 @@ "psr", "psr-3" ], - "time": "2016-10-10 12:19:37" + "time": "2019-11-01T11:05:21+00:00" }, { "name": "react/event-loop", @@ -220,7 +219,7 @@ "asynchronous", "event-loop" ], - "time": "2017-04-27 10:56:23" + "time": "2017-04-27T10:56:23+00:00" }, { "name": "react/zmq", @@ -265,7 +264,7 @@ "zeromq", "zmq" ], - "time": "2014-05-25 17:54:51" + "time": "2014-05-25T17:54:51+00:00" } ], "packages-dev": [], @@ -275,7 +274,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5" + "php": ">=7.0.8" }, - "platform-dev": [] + "platform-dev": [], + "platform-overrides": { + "php": "7.0.8", + "ext-zmq": "1" + } } diff --git a/docker-compose.yml b/docker-compose.yml index 95a690f..29589cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,4 +4,6 @@ services: xmr: build: . environment: - XMR_DEBUG: "true" \ No newline at end of file + XMR_DEBUG: "true" + volumes: + - ./:/opt/xmr \ No newline at end of file diff --git a/index.php b/index.php index ff0daa3..d69661b 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,24 @@ #!/usr/bin/env php . * sequenceDiagram Player->> CMS: Register diff --git a/tests/playerReq.php b/tests/playerReq.php new file mode 100644 index 0000000..02e2644 --- /dev/null +++ b/tests/playerReq.php @@ -0,0 +1,19 @@ + +*/ + +$context = new ZMQContext(); + +// Socket to talk to server +echo "Connecting to hello world server…\n"; +$requester = new ZMQSocket($context, ZMQ::SOCKET_REQ); +$requester->connect("tcp://192.168.86.88:58587"); +echo "connected\n"; +$requester->send("Hello"); +echo "sent\n"; +$reply = $requester->recv(); +echo "Received reply " . $reply; \ No newline at end of file diff --git a/tests/playerSub.php b/tests/playerSub.php index 8fe426a..11965a4 100644 --- a/tests/playerSub.php +++ b/tests/playerSub.php @@ -1,8 +1,23 @@ . * * This is a player subscription mock file. * docker exec -it xiboxmr_xmr_1 sh -c "cd /opt/xmr/tests; php playerSub.php 1234" @@ -16,19 +31,21 @@ $identity = $argv[1]; // Use the same settings as the running XMR instance -$config = json_decode(file_get_contents('../config.json')); +#$config = json_decode(file_get_contents('../config.json')); $fp = fopen('key.pem', 'r'); $privateKey = openssl_get_privatekey(fread($fp, 8192)); fclose($fp); +echo 'Sub to: ' . $identity; + // Sub $loop = React\EventLoop\Factory::create(); $context = new React\ZMQ\Context($loop); $sub = $context->getSocket(ZMQ::SOCKET_SUB); -$sub->connect($config->pubOn[0]); +$sub->connect('tcp://192.168.86.88:36740'); $sub->subscribe("H"); $sub->subscribe($identity); @@ -40,23 +57,13 @@ return; // Expect messages to have a length of 3 - if (count($msg) != 3) - throw new InvalidArgumentException('Incorrect Message Length'); + //if (count($msg) != 3) + // throw new InvalidArgumentException('Incorrect Message Length'); // Message will be channel, key, message - if ($msg[0] != $identity) - throw new InvalidArgumentException('Channel does not match'); - - // Decrypt the message using our private key - $opened = null; - - $key = base64_decode($msg[1]); - $message = base64_decode($msg[2]); - - if (!openssl_open($message, $opened, $key, $privateKey)) - throw new Exception('Encryption Error'); + //if ($msg[0] != $identity) + // throw new InvalidArgumentException('Channel does not match'); - echo 'Message: ' . $opened . PHP_EOL; } catch (InvalidArgumentException $e) { echo $e->getMessage() . PHP_EOL;