{"id":18447067,"url":"https://github.com/zot/libp2p-websocket","last_synced_at":"2025-06-10T17:08:03.776Z","repository":{"id":48497692,"uuid":"238546331","full_name":"zot/libp2p-websocket","owner":"zot","description":"A websocket server for using and managing IPFS p2p connections (forward and listen)","archived":false,"fork":false,"pushed_at":"2022-12-08T21:52:33.000Z","size":29890,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T09:55:19.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/zot.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":"2020-02-05T20:52:55.000Z","updated_at":"2020-08-20T16:39:31.000Z","dependencies_parsed_at":"2023-01-25T18:16:33.126Z","dependency_job_id":null,"html_url":"https://github.com/zot/libp2p-websocket","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/zot%2Flibp2p-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Flibp2p-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Flibp2p-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Flibp2p-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zot","download_url":"https://codeload.github.com/zot/libp2p-websocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Flibp2p-websocket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259114475,"owners_count":22807245,"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":[],"created_at":"2024-11-06T07:11:52.553Z","updated_at":"2025-06-10T17:08:03.741Z","avatar_url":"https://github.com/zot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LIBP2P-WEBSOCKET\n\nRelay p2p connections between browsers transcoding between sockets and websockets\n\nThis runs a simple websocket server and listens for websocket connections using a simple protocol:\n\n## NOTE: THIS IS A WORK IN PROGRESS\n\n# LICENSE AND COPYRIGHT\nCopyright (c) 2020, William R. Burdick Jr., Roy Riggs, and TEAM CTHLUHU. All rights reserved.\nUse of this source code is governed by an MIT-style\nlicense that can be found in the LICENSE file.\n\n# Running\n\n`./libp2p-websocket -browser chat.html` will start the relay and pop the chat example in a browser\n\nIn development, you can use -files to point to the live html/js/css files you are editing. If you are in the src directory. For example, you should be able to use this command to pop out a development version of chat:\n```\nlibp2p-websocket -files html -files examples -browse chat.html\n```\n\n## Usage:\n```\nUsage of libp2p-websocket:\n  -addr string\n        host address to listen on\n  -browse string\n        Browse a URL\n  -files value\n        add the contents of a directory to serve from /\n  -key string\n        specify peer key\n  -listen value\n        Adds a multiaddress to the listen list\n  -nopeers\n        clear the bootstrap peer list\n  -peer value\n        Adds a peer multiaddress to the bootstrap list\n  -port int\n        port to listen on (default 8888)\n```\n\n# libp2p-websocket runs a websocket server on /libp2p\nThis allows a browser to control the relay using a very simple binary protocol.\nWhen a connection closes, it cleans up all of its child connections.\nThe client and server exchange these command messages, with the first byte of each message identifying the command.\n\n# CLIENT-TO-SERVER MESSAGES\n \n```\n  Start:       [0][KEY: str] -- start peer with optional peer key\n  Listen:      [1][FRAMES: 1][PROTOCOL: rest] -- request a listener for a protocol (frames optional)\n  Stop:        [2][PROTOCOL: rest] -- stop listening to PROTOCOL\n  Close:       [3][ID: 8]                     -- close a stream\n  Data:        [4][ID: 8][data: rest]         -- write data to stream\n  Connect:     [5][FRAMES: 1][PROTOCOL: STR][RELAY: STR][PEERID: rest] -- connect to another peer (frames optional)\n```\n\n## Including peer addresses with the peerid\n\nThe connect message allows a peer ID or a peer ID plus its addresses. This allows connection to peers without relying on discovery techniques. Users can exchange addresses over other channels, like chat programs.\n\nA peer ID plus its addresses are encoded as\n\n`/addrs/BASE85JSON` where BASE85JSON is a JSON object encoded in base85. The JSON object is like this:\n\n```json\n{\n    \"peerID\": PEERID,\n    \"addrs\": [MULTIADDR,...]\n}\n\n```\n\n# SERVER-TO-CLIENT MESSAGES\n\n```\n  Hello:                   [0][STARTED: 1] -- hello message indicates whether the peer needs starting\n  Identify:                [1][PUBLIC: 1][PEERID: str][ADDRESSES: str][KEY: rest] -- successful initialization\n  Listener Connection:     [2][ID: 8][PEERID: str][PROTOCOL: rest] -- new listener connection with id ID\n  Connection Closed:       [3][ID: 8][REASON: rest]            -- connection ID closed\n  Data:                    [4][ID: 8][data: rest]              -- receive data from stream with id ID\n  Listen Refused:          [5][PROTOCOL: rest]                 -- could not listen on PROTOCOL\n  Listener Closed:         [6][PROTOCOL: rest]                 -- could not listen on PROTOCOL\n  Peer Connection:         [7][ID: 8][PEERID: str][PROTOCOL: rest] -- connected to a peer with id ID\n  Peer Connection Refused: [8][PEERID: str][PROTOCOL: str][ERROR: rest] -- connection to peer PEERID refused\n  Protocol Error:          [9][MSG: rest]                      -- error in the protocol\n  Listening:               [10][PROTOCOL: rest]                -- confirmation that listening has started\n```\n\n# Building\n\n## Prerequisites\n**go**: you need [go](https://golang.org/) if you want to build the go part (which includes updating the default HTML files)\n\n**esc:** `go get -u github.com/mjibson/esc` -- make sure this is on your path (it should go into $GOHOME/bin).\n\n## Building the default webdir\n\nThe `src/build` file is (probably?) a posix shell script that uses esc to generate files.go by combining examples/* and html/* into a directory and creating a virtual file system out of which the HTTP server serves files.\n\n## build-and-run\n\nGo compiles so fast that, while I'm developing, I build the entire project everytime I run it:\n\n```shell\ncd src\n./build \u0026\u0026 go build libp2p-websocket.go protocol.go files.go \u0026\u0026 ./libp2p-websocket -browse chat.html\n```\nThis creates an updated files.go, compiles the project, and then runs the chat example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzot%2Flibp2p-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzot%2Flibp2p-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzot%2Flibp2p-websocket/lists"}