{"id":19325413,"url":"https://github.com/krypt0nn/bpn","last_synced_at":"2025-10-07T05:23:04.810Z","repository":{"id":57009439,"uuid":"397253404","full_name":"krypt0nn/bpn","owner":"krypt0nn","description":"Bit Points Network - your personal decentralized network in PHP 8","archived":false,"fork":false,"pushed_at":"2021-08-28T12:30:29.000Z","size":78,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T20:47:31.666Z","etag":null,"topics":["decentralized","network","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krypt0nn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-17T12:45:39.000Z","updated_at":"2023-10-26T20:38:42.000Z","dependencies_parsed_at":"2022-08-21T14:50:57.701Z","dependency_job_id":null,"html_url":"https://github.com/krypt0nn/bpn","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/krypt0nn/bpn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fbpn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fbpn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fbpn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fbpn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krypt0nn","download_url":"https://codeload.github.com/krypt0nn/bpn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fbpn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722757,"owners_count":26034463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decentralized","network","php"],"created_at":"2024-11-10T02:09:59.332Z","updated_at":"2025-10-07T05:23:04.775Z","avatar_url":"https://github.com/krypt0nn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"bpn.png\" width=\"384px\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/krypt0nn/bpn\"\u003e\u003cimg src=\"https://poser.pugx.org/krypt0nn/bpn/v\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/krypt0nn/bpn\"\u003e\u003cimg src=\"https://poser.pugx.org/krypt0nn/bpn/downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"/LICENSE\"\u003e\u003cimg src=\"https://poser.pugx.org/krypt0nn/bpn/license\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    🚀 \u003cb\u003eBPN\u003c/b\u003e is a huge library which allows you to create your own decentralized network on PHP 8+ \u003cbr\u003e\n    and provides various communication tools\n\u003c/p\u003e\n\n## Installation\n\n```\ncomposer require krypt0nn/bpn\n```\n\n## Usage example\n\n### Communication through events with unprotected UDP packets\n\nclient.php\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse BPN\\BPN;\nuse BPN\\Networking\\Endpoint;\nuse BPN\\Encoding\\ECC;\nuse BPN\\Data\\Packet;\n\n$keypair = ECC::generateKeyPair();\n\nBPN::configure ([\n    'public_key'  =\u003e $keypair['public'],\n    'private_key' =\u003e $keypair['private']\n]);\n\nBPN::get()-\u003esend (\n    Endpoint::format('server address'),\n    Packet::performEvent('hello-world', 'Hello, World!')\n);\n```\n\nserver.php\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse BPN\\BPN;\nuse BPN\\Networking\\Endpoint;\nuse BPN\\Encoding\\ECC;\n\n$keypair = ECC::generateKeyPair();\n\nBPN::configure ([\n    'public_key'  =\u003e $keypair['public'],\n    'private_key' =\u003e $keypair['private']\n]);\n\nBPN::on('hello-world', fn (Packet $packet) =\u003e echo $packet-\u003edata['data'] . PHP_EOL);\n\nwhile (true)\n    BPN::get()-\u003eupdate();\n```\n\n### Direct connection through protected TCP tunnel\n\nclient.php\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse BPN\\BPN;\nuse BPN\\Networking\\Endpoint;\nuse BPN\\Networking\\Tunneling\\Tunnel;\nuse BPN\\Encoding\\ECC;\n\n$keypair = ECC::generateKeyPair();\n\nBPN::configure ([\n    'public_key'  =\u003e $keypair['public'],\n    'private_key' =\u003e $keypair['private']\n]);\n\n$tunnel = Tunnel::create(Endpoint::format('server address'));\n\nif ($tunnel === null)\n    die ('Tunnel creation error');\n\nelse while (true)\n{\n    $message = readline ('\u003e ');\n\n    $tunnel-\u003esend ($message);\n}\n```\n\nserver.php\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse BPN\\BPN;\nuse BPN\\Networking\\Endpoint;\nuse BPN\\Networking\\Tunneling\\Tunnel;\n\n$keypair = ECC::generateKeyPair();\n\nBPN::configure ([\n    'public_key'  =\u003e $keypair['public'],\n    'private_key' =\u003e $keypair['private']\n]);\n\nwhile (!($tunnel = Tunnel::listen(Endpoint::local())));\n\nwhile (true)\n{\n    $tunnel-\u003eupdate (function ($data)\n    {\n        echo $data . PHP_EOL;\n    });\n}\n```\n\n### Search client through BPN network by his UUID\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse BPN\\BPN;\nuse BPN\\Networking\\DNS;\nuse BPN\\Networking\\DNS\\Record;\nuse BPN\\Data\\Packet;\n\n$keypair = ECC::generateKeyPair();\n\nBPN::configure ([\n    'public_key'  =\u003e $keypair['public'],\n    'private_key' =\u003e $keypair['private']\n]);\n\nDNS::searchRecords ('client uuid', function (Record $record, Packet $packet)\n{\n    echo 'Client with endpoint '. $packet-\u003eauthor_endpoint-\u003etoString() .\n         ' found client we wanted to find'.\n         ' and his endpoint is '. $record-\u003eendpoint()-\u003etoString() . PHP_EOL;\n\n    // if you want to not to receive another records\n    // you can return false from this callback\n    // return false;\n});\n```\n\n### Broadcast data\n\n```php\n\u003c?php\n\nuse BPN\\BPN;\n\n$keypair = ECC::generateKeyPair();\n\nBPN::configure ([\n    'public_key'  =\u003e $keypair['public'],\n    'private_key' =\u003e $keypair['private']\n]);\n\n# Add broadcast handler for incoming data\nBPN::onBroadcast(function ($data)\n{\n    echo '['. $data['author'] .'] '. $data['message'] . PHP_EOL;\n});\n\n# Broadcast data\nBPN::broadcast ([\n    'author'  =\u003e 'aboba',\n    'message' =\u003e 'Hello, World!'\n]);\n```\n\n## Documentation\n\nDocumentation will be added in future\n\n\u003cbr\u003e\n\nAuthor: [Nikita Podvirnyy](https://vk.com/technomindlp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrypt0nn%2Fbpn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrypt0nn%2Fbpn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrypt0nn%2Fbpn/lists"}