{"id":30499548,"url":"https://github.com/bitvora/sw2","last_synced_at":"2026-01-26T00:45:12.006Z","repository":{"id":266703007,"uuid":"898776490","full_name":"bitvora/sw2","owner":"bitvora","description":"Nostr Relay: Simple With Whitelisting","archived":false,"fork":false,"pushed_at":"2025-02-19T14:02:53.000Z","size":6325,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T07:47:28.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bitvora.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-12-05T02:33:21.000Z","updated_at":"2025-08-22T05:24:53.000Z","dependencies_parsed_at":"2024-12-05T17:19:39.254Z","dependency_job_id":"c24bb57c-c096-42e4-abcb-f5fbf71843af","html_url":"https://github.com/bitvora/sw2","commit_stats":null,"previous_names":["bitvora/sw2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bitvora/sw2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitvora%2Fsw2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitvora%2Fsw2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitvora%2Fsw2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitvora%2Fsw2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitvora","download_url":"https://codeload.github.com/bitvora/sw2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitvora%2Fsw2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28763019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T00:37:26.264Z","status":"ssl_error","status_checked_at":"2026-01-26T00:37:25.959Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-08-25T07:01:08.886Z","updated_at":"2026-01-26T00:45:12.001Z","avatar_url":"https://github.com/bitvora.png","language":"Go","funding_links":[],"categories":["Relays"],"sub_categories":["Implementations"],"readme":"# Simple With Whitelisting (sw2)\n\nSimple With Whitelisting (sw2) is a nostr relay that displays and accepts notes only from whitelisted pubkeys.\n\nIt's built on the [Khatru](https://khatru.nostr.technology) framework.\n\n## Prerequisites\n\n- **Go**: Ensure you have Go installed on your system. You can download it from [here](https://golang.org/dl/).\n- **Build Essentials**: If you're using Linux, you may need to install build essentials. You can do this by running `sudo apt install build-essential`.\n\n## Use Cases\n\nThis relay can suit a variety of uses:\n\n- **Running a small community**: Community members are whitelisted to read and post notes.\n- **Running a knowledge base**: Users are whitelisted to read notes, but only administrators can post notes.\n- **Running a blind dropbox**: Users are whitelisted to post notes, but only the administrator can read notes.\n- **Combinations of the above**: A Community where members can read and post, and guests can read only.\n\n## Setup Instructions\n\nFollow these steps to get the sw2 Relay running on your local machine:\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/bitvora/sw2.git\ncd sw2\n```\n\n### 2. Copy `.env.example` to `.env`\n\nYou'll need to create an `.env` file based on the example provided in the repository.\n\n```bash\ncp .env.example .env\n```\n\n### 3. Set your environment variables\n\nOpen the `.env` file and set the necessary environment variables. Example variables include:\n\n```bash\nRELAY_NAME=\"utxo's bot relay\"\nRELAY_PUBKEY=\"e2ccf7cf20403f3f2a4a55b328f0de3be38558a7d5f33632fdaaefc726c1c8eb\"\nRELAY_DESCRIPTION=\"all my bots will use this relay\"\nRELAY_URL=\"wss://bots.utxo.one\"\nRELAY_ICON=\"https://pfp.nostr.build/d8fb3b6100a0eb9e652bbc34a0c043b7f225dc74e4ed6d733d0e059f9bd444d4.jpg\"\nRELAY_CONTACT=\"https://utxo.one\"\n```\n\n### 4.1 Whitelist Pubkeys for Reading Notes\n\nOpen the `read_whitelist.json` file and add pubkeys to the array\n\n```json\n{\n  \"pubkeys\": [\n    \"1c6cb22996baabe921bcd45c8b6213b2dab096f88e4ba5678d43d195a1868551\",\n    \"9c5d0b120f01b75292d2a2bc32972bf918c8dd8927eaa633d3f62e181a292b27\",\n    \"1bda7e1f7396bda2d1ef99033da8fd2dc362810790df9be62f591038bb97c4d9\"\n  ]\n}\n```\n\nIf the `read_whitelist.json` contains no pubkeys `{\"pubkeys\": []}`, then all users are authorised to read.\n\n### 4.2 Whitelist Pubkeys for Posting Notes\n\nOpen the `write_whitelist.json` file and add pubkeys to the array\n\n```json\n{\n  \"pubkeys\": [\n    \"1c6cb22996baabe921bcd45c8b6213b2dab096f88e4ba5678d43d195a1868551\",\n    \"9c5d0b120f01b75292d2a2bc32972bf918c8dd8927eaa633d3f62e181a292b27\",\n    \"ede41352397758154514148b24112308ced96d121229b0e6a66bc5a2b40c03ec\"\n  ]\n}\n```\n\nIf the `write_whitelist.json` contains no pubkeys `{\"pubkeys\": []}`, then all users are authorised to write.\n\nTo maintain compatibliity with previous versions of SW2, a file `whitelist.json` can be used instead of `write_whitelist.json` if you prefer.\n\n### 5. Build the project\n\nRun the following command to build the relay:\n\n```bash\ngo build\n```\n\n### 6. Create a Systemd Service (optional)\n\nTo have the relay run as a service, create a systemd unit file.\n\n1. Create the file:\n\n```bash\nsudo nano /etc/systemd/system/sw2.service\n```\n\n2. Add the following contents:\n\n```ini\n[Unit]\nDescription=sw2 Relay Service\nAfter=network.target\n\n[Service]\nExecStart=/home/ubuntu/sw2/sw2\nWorkingDirectory=/home/ubuntu/sw2\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n```\n\n3. Reload systemd to recognize the new service:\n\n```bash\nsudo systemctl daemon-reload\n```\n\n4. Start the service:\n\n```bash\nsudo systemctl start sw2\n```\n\n5. (Optional) Enable the service to start on boot:\n\n```bash\nsudo systemctl enable sw2\n```\n\n#### Permission Issues on Some Systems\n\nthe relay may not have permissions to read and write to the database. To fix this, you can change the permissions of the database folder:\n\n```bash\nsudo chmod -R 777 /path/to/db\n```\n\n### 7. Serving over nginx (optional)\n\nYou can serve the relay over nginx by adding the following configuration to your nginx configuration file:\n\n```nginx\nserver {\n    listen 80;\n    server_name yourdomain.com;\n\n    location / {\n        proxy_pass http://localhost:3334;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n    }\n}\n```\n\nReplace `yourdomain.com` with your actual domain name.\n\nAfter adding the configuration, restart nginx:\n\n```bash\nsudo systemctl restart nginx\n```\n\n### 8. Install Certbot (optional)\n\nIf you want to serve the relay over HTTPS, you can use Certbot to generate an SSL certificate.\n\n```bash\nsudo apt-get update\nsudo apt-get install certbot python3-certbot-nginx\n```\n\nAfter installing Certbot, run the following command to generate an SSL certificate:\n\n```bash\nsudo certbot --nginx\n```\n\nFollow the instructions to generate the certificate.\n\n### 8. Access the relay\n\nOnce everything is set up, the relay will be running on `localhost:3334` or your domain name if you set up nginx.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitvora%2Fsw2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitvora%2Fsw2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitvora%2Fsw2/lists"}