{"id":25131950,"url":"https://github.com/robotomize/powwy","last_synced_at":"2025-10-10T11:34:17.674Z","repository":{"id":64303088,"uuid":"497443615","full_name":"robotomize/powwy","owner":"robotomize","description":"A toy implementation of a tcp server with its own simple text protocol with content protection from ddos attacks using proof of work.","archived":false,"fork":false,"pushed_at":"2023-05-23T09:05:29.000Z","size":50,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T03:22:36.309Z","etag":null,"topics":["ddos","golang","hashcash","hashcash-algorithm","proof-of-work","tcp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robotomize.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-28T22:52:49.000Z","updated_at":"2024-11-16T02:43:24.000Z","dependencies_parsed_at":"2024-06-20T09:29:00.088Z","dependency_job_id":"2c19f735-d52a-4e10-a4af-8bd4d2fdcae2","html_url":"https://github.com/robotomize/powwy","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotomize%2Fpowwy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotomize%2Fpowwy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotomize%2Fpowwy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robotomize%2Fpowwy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robotomize","download_url":"https://codeload.github.com/robotomize/powwy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513380,"owners_count":21443200,"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":["ddos","golang","hashcash","hashcash-algorithm","proof-of-work","tcp"],"created_at":"2025-02-08T14:16:03.027Z","updated_at":"2025-10-10T11:34:12.633Z","avatar_url":"https://github.com/robotomize.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Powwy\n\n[![codebeat badge](https://codebeat.co/badges/a4a12b24-98e6-4627-b01c-8b124561f2e1)](https://codebeat.co/projects/github-com-robotomize-powwy-main)\n[![Build status](https://github.com/robotomize/powwy/actions/workflows/release.yml/badge.svg)](https://github.com/robotomize/powwy/actions)\n[![GitHub license](https://img.shields.io/github/license/robotomize/powwy.svg)](https://github.com/robotomize/powwy/blob/master/LICENSE)\n\nA toy implementation of a tcp server with its own simple text protocol with content protection from ddos attacks using\nproof of work.\n\nThe project consists of a tcp server and a tcp client.\nThe server offers to solve the proof of work problem to the client in order to access the content.  \nThe client receives the problem, solves it, and receives a quote from Words of wisdom.\n\n## Requirements\n\n* go1.18\n* golangci-lint\n\n## Usage\n\nInstall from local go toolkit [Go 1.18](https://go.dev/dl/)\n\n### Go install\n```sh\ngo install ./cmd/powwy-srv\ngo install ./cmd/powwy-cli\n    \n```\n\n### Make build\n\n```sh\nmake build\n```\n\n### Docker install\n\n```sh\nsudo docker build -it powwy-cli -f ./docker/client.Dockerfile .\nsudo docker build -it powwy -f ./docker/server.Dockerfile .\n\nsudo docker run powwy --net=host -p 3333:3333\nsudo docker run powwy-cli -a localhost:3333 -d // infinite loop\n\nsudo docker run powwy-cli compute \u003cheader\u003e\n```\n\nFrom docker hub\n```sh\ndocker pull robotomize/powwy-cli:latest\ndocker pull robotomize/powwy-srv:latest\n```\n\n### Docker compose\n\n```sh\nsudo docker-compose up\n```\n\n## CLI powwy\n\nFind a solution to the HashCash header problem\n\n```sh\npowwy-cli compute \u003cheader1\u003e \u003cheader2\u003e \n```\n\n```sh\nUsage: powwy-cli compute \u003cheader\u003e \u003cheader\u003e \u003cheader\u003e\n\nUsage:\n\ncompute [flags]\n\nFlags:\n-h, --help   help for compute\n\nGlobal Flags:\n-d, --duration duration   -d 10s (default -1ns)\n-i, --iterations int      -i 1000000 (default -1)\n-w, --workers int         -w 4 (default 2)\n```\n\nConnect to powwy server and fetch quotes\n\n```sh\npowwly-cli -a localhost:3333\n```\n\n```sh\nUsage:\n\nAvailable Commands:\ncompletion  Generate the autocompletion script for the specified shell\ncompute     Usage: powwy-cli compute \u003cheader\u003e \u003cheader\u003e \u003cheader\u003e\nhelp        Help about any command\n\nFlags:\n-a, --addr string         -a localhost:3333 (default \"localhost:3333\")\n-s, --dos                 -s true\n-d, --duration duration   -d 10s (default -1ns)\n-h, --help                help for this command\n-i, --iterations int      -i 1000000 (default -1)\n-n, --network string      -n tcp4 (default \"tcp\")\n-w, --workers int         -w 4 (default 2)\n\nUse \" [command] --help\" for more information about a command.\n```\n\n## Proof of work\n\n### HashCash\n\nThe [http://www.hashcash.org/](HashCash) algorithm was chosen to implement the proof of work mechanism\n\nPros:\n* Easy to find description\n* Easy to implement\n\nCons:\n* Difficult to adjust the difficulty of the task\n\n### Implementing the header\n\n*HashCashHeader: version:difficult:expiredAt:subject:alg:nonce:counter*\n\n* version - version of the header, represented by an int\n* difficult - the complexity of the useful work, expressed in the number of first zeros of the hash\n* expiredAt - the lifetime of the task, after which it is considered invalid\n* subject - defines the name of the resource or other identifying information, such as a user ID or its ip address\n* alg - determines what type of hash to use\n* nonce - is a randomly generated set of bytes\n* counter - Current counter value\n\n*Example 1:20:1665396610:localhost:sha-512:hVscDCMZcS1WYg==:BQAAAAAAAAA=*\n\n### Merkle tree\n\n[Merkle in ethereum](https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/)\n\nPros:\n  Works great for decentralized applications\n\nCons:\n  Not very suitable for the implementation of client-server applications\n\n## Protocol\n\npowwy uses a simple command text protocol\n\nList of available commands\n\n```go\n// Proto specification tags\nconst (\n    REQ = \"REQ\" // REQ - request challenge\n    RES = \"RES\" // RES - request resource\n    RSV  = \"RSV\" // RSV - response with payload\n    OK = \"OK\"    // OK - command accepted\n    ERR = \"ERR\"   // ERR - command err\n    DISC = \"DISC\" // DISC - initialize close connection\n)\n\n```\n\nFormat:\n`\u003cCommand\u003e \u003cbody length\u003e |\u003cbody\u003e`\nor\n`\u003cCommand\u003e`\n\nExample:\n\n```sh\n---------------------------------------------------------------------------------------------------------------\nUNKNOWN_COMMAND\nERR 18 |command wrong\n---------------------------------------------------------------------------------------------------------------\nREQ\nERR 21 |internal server error\n---------------------------------------------------------------------------------------------------------------\nREQ\nRSR 62 |\u003ctoken\u003e\n1:5:1665396610:localhost:sha-256:vZOxuoIgixP+hw==:AAAAAAAAAAA=\n---------------------------------------------------------------------------------------------------------------\nRES 62 |\u003ctoken\u003e\n1:5:1665396610:localhost:sha-256:vZOxuoIgixP+hw==:FxUQAAAAAAA=\nRST 139 |Voice is not just the sound that comes from your throat, but the feelings that come from your words.\n― Jennifer Donnelly, A Northern Light\n---------------------------------------------------------------------------------------------------------------\nDISC\nOK\n---------------------------------------------------------------------------------------------------------------\n```\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotomize%2Fpowwy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobotomize%2Fpowwy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobotomize%2Fpowwy/lists"}