Skip to content

Commit

Permalink
Merge pull request #20 from dasgarner/develop
Browse files Browse the repository at this point in the history
Update for alpine 3.11
  • Loading branch information
dasgarner authored Jan 7, 2020
2 parents 1379547 + 8a7ab71 commit e0df705
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.json
vendor/
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ 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 <[email protected]>
FROM alpine:3.11
MAINTAINER Xibo Signage Ltd <[email protected]>

ENV XMR_DEBUG false
ENV XMR_QUEUE_POLL 5
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

Expand Down
Binary file modified bin/xmr.phar
Binary file not shown.
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,30 @@
"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",
"homepage": "https://github.com/xibosignage/xibo/tree/master/contributors"
}
],
"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"
}
Expand Down
41 changes: 22 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ services:
xmr:
build: .
environment:
XMR_DEBUG: "true"
XMR_DEBUG: "true"
volumes:
- ./:/opt/xmr
23 changes: 19 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
#!/usr/bin/env php
<?php
/*
* Spring Signage Ltd - http://www.springsignage.com
* Copyright (C) 2015-2017 Spring Signage Ltd
* (index.php)
/**
* Copyright (C) 2020 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*
sequenceDiagram
Player->> CMS: Register
Expand Down
19 changes: 19 additions & 0 deletions tests/playerReq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/*
* Hello World client
* Connects REQ socket to tcp://localhost:5555
* Sends "Hello" to server, expects "World" back
* @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
*/

$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;
47 changes: 27 additions & 20 deletions tests/playerSub.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
<?php
/*
* Spring Signage Ltd - http://www.springsignage.com
* Copyright (C) 2015-18 Spring Signage Ltd
* (playerSub.php)
/**
* Copyright (C) 2020 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*
* This is a player subscription mock file.
* docker exec -it xiboxmr_xmr_1 sh -c "cd /opt/xmr/tests; php playerSub.php 1234"
Expand All @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit e0df705

Please sign in to comment.