denpa/php-levin

Pure PHP implementation of monero's Levin protocol.

v1.0.1 2019-02-23 22:46 UTC

This package is auto-updated.

Last update: 2024-12-06 06:57:53 UTC


README

Latest Stable Version License ci Code Climate Code Coverage

Example

require 'vendor/autoload.php';

use Denpa\Levin;

$vars = [
    'network_id' => 'somenetwork',
];

Levin\connection($ip, $port, $vars)->connect(
    function ($bucket, $connection) {
        if ($bucket->isRequest('supportflags', 'timedsync', 'ping')) {
            // respond to supportflags, timedsync and ping requests
            // to keep the connection open
            $connection->write($bucket->response());
        }

        if ($bucket->isResponse('handshake')) {
            // send ping request to the server after
            // receiving handshake response
            $connection->write(Levin\request('ping'));
        }

        if ($bucket->isResponse('ping')) {
            // dump server response to the console
            var_dump($bucket->getPayload());

            // returning false closes connection
            return false;
        }
    }
);

Request Support

Notification Support

Exceptions

  • Denpa\Levin\Exceptions\ConnectionException - thrown on connection errors.
  • Denpa\Levin\Exceptions\EntryTooLargeException - thrown when type or packet size is too large.
  • Denpa\Levin\Exceptions\SignatureMismatchException - thrown on section or bucket signature mismatches.
  • Denpa\Levin\Exceptions\UnexpectedTypeException - thrown on unexpected or invalid type.
  • Denpa\Levin\Exceptions\UnknownCommandException - thrown on unknown command.
  • Denpa\Levin\Exceptions\UnpackException - thrown when unable to unpack binary data.

License

This product is distributed under the MIT license.

Credits

Loosely based on py-levin.

Donations

If you like this project, you can donate using one of the following addresses:

BTC:
3L6dqSBNgdpZan78KJtzoXEk9DN3sgEQJu
Monero:
458j3EKczYFEE1Gku9ENUgTj4KUtHbqP9hT82vFRdZHiBRfbVFDUE7QArtAB63cNZiKMgBgwrD4k1Wtac8ZgoKx2GUHFpo2
Safex:
Safex61BqfGVucrCo71xPxhQi4L1oMaRYUHwBKMuHVy8UTR1HkBjhJx4WafkLvhSwUeshkonyDjvYFiBrRDeEcrL5k6JLALD85L2T

❤Thanks for your support!❤