{"id":25127771,"url":"https://github.com/zerdicorp/p2p_network","last_synced_at":"2025-04-02T20:45:11.537Z","repository":{"id":44342495,"uuid":"507829694","full_name":"ZERDICORP/p2p_network","owner":"ZERDICORP","description":"Oh, I've been wanting to play with P2P networks for so long!","archived":false,"fork":false,"pushed_at":"2023-02-13T01:21:59.000Z","size":166,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T11:18:00.579Z","etag":null,"topics":["curiosity","decentralized-network","file-storage","network","p2p","peer-to-peer","storage"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZERDICORP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-27T08:42:49.000Z","updated_at":"2023-03-09T10:59:15.000Z","dependencies_parsed_at":"2022-08-29T07:52:03.049Z","dependency_job_id":null,"html_url":"https://github.com/ZERDICORP/p2p_network","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fp2p_network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fp2p_network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fp2p_network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZERDICORP%2Fp2p_network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZERDICORP","download_url":"https://codeload.github.com/ZERDICORP/p2p_network/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246892779,"owners_count":20850846,"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","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":["curiosity","decentralized-network","file-storage","network","p2p","peer-to-peer","storage"],"created_at":"2025-02-08T11:18:09.164Z","updated_at":"2025-04-02T20:45:11.519Z","avatar_url":"https://github.com/ZERDICORP.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# p2p_network 🕸️ \n#### Oh, I've been wanting to play with P2P networks for so long!\n\n## What is it? :eyes:\nWell, the other day I watched the series **Silicon Valley**, in which a group of enthusiasts developed a compression algorithm.  \nBut I was attracted not so much by the compression algorithm as by its application, one of which was a decentralized data storage.  \nAnd then I remembered that I had long wanted to create such a network. And then... That's right, then I started to implement it.\n\n***Did I succeed?*** Let's just say I'm not disappointed.  \nThe network turned out to be working. Files are sharded, shards are encrypted and distributed between nodes.  \nEverything is like in the series.\n\n***Should you use this network?*** Oh no!  \nMy implementation of a decentralized p2p network is just an introductory project with no expectation of mass use (to be honest, the project smacks of various optimization problems).\n\n***Why didn't I solve the problem?*** Everything is simple - it makes no sense.  \nMy whole interest was to figure out how such a network functions, how nodes learn about each other, how they communicate, and so on.  \nAnd things like query parallelization and other optimizations are simply superfluous, since the project is just for fun, besides, the network was tested on only 3 nodes, so the performance that we have now is quite enough.\n\n## How it works? :hand:\n\u003e Before reading further, let's agree on the meanings of the following words:  \n\u003e **node** - *java program; socket server.*\n\n### «Acquaintance»\nAfter launching a new node, it is not yet in the p2p network.  \nTo get there, it needs to tell all other nodes that it exists.  \nTo do this, it needs to send some notification to one of the network nodes (such a node can also be called the root node).  \nAfter notifying the root node, all other nodes will be notified that a new node has joined the network.\n\n### «Cloning nodes»\nAs soon as the whole network knows about the existence of a new node, it adds the address of this node to the \"address book\".  \nThus, this node becomes a member of the network.  \nBut what about the newest node? What about his address book? How can he find out about the nodes of the network?  \nHere, the node must request an \"address book\" from the root node.\n\n### «Data sharing»\nNow that the new node knows about the other nodes, it can exchange data between them.  \nThat is, the owner of a node can ask that node to store some data on the network.  \nThe node will then make multiple copies of this data and send each copy to a different node, providing storage and backup.\n\n### «Anything else»\nAll of the above is the simplest version of this kind of network. But the idea is conveyed correctly.  \nAs an addition, you can implement data sharding (breaking into small segments) and encrypting them.\n\n## How to become a member of the network? :couple:\n\u003e It's important to note that although the repository is referred to as a \"p2p network\", it's actually just one node.  \n\u003e And the network will be reached when the number of nodes \u003e 1, simultaneously working and connected with each other.\n\n#### 1. Clone the repository\n```\n$ git clone https://github.com/ZERDICORP/p2p_network.git\n```\n\n#### 2. Use maven\n```\n$ cd p2p_network\n$ mvn clean compile assembly:single\n```\n\n#### 3. Start node\n\u003e Below, my server acts as the root node.\n```\n$ echo \"java -jar target/p2p_network-1.0-SNAPSHOT-jar-with-dependencies.jar \\$@\" \u003e p2p \u0026\u0026 chmod +x p2p\n$ ./p2p -s 95.165.89.228\n[log]: server has been started on port 8080..\n```\n\n#### 4. Сlient usage\n\u003e When executing each command on the client, you will need to enter a secret (it can be different for each file).\n+ **Saving a file**\n\u003e The contents of the \"file.txt\":  \n\u003e Hello, world!\n```\n$ ./p2p -c save /path/to/file.txt\n[\u003e] enter secret: \n[log]: file saved successfully!\n```\n+ **Getting a file**\n```\n$ ./p2p -c cat file.txt\n[\u003e] enter secret: \nHello, world!\n```\n\u003e Or if you want the result to be written to a file\n```\n$ ./p2p -c cat file.txt -o out.txt\n[\u003e] enter secret:\n[log]: file contents are written to: out.txt\n```\n+ **Renaming a file**\n```\n$ ./p2p -c mv file.txt newFileName.txt\n[\u003e] enter secret: \n[log]: file renamed successfully!\n```\n+ **Deleting a file**\n```\n$ ./p2p -c rm file.txt\n[\u003e] enter secret:\n[log]: file deleted successfully!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerdicorp%2Fp2p_network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerdicorp%2Fp2p_network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerdicorp%2Fp2p_network/lists"}