{"id":36446467,"url":"https://github.com/abecli/subnet","last_synced_at":"2026-01-15T02:06:24.794Z","repository":{"id":316177477,"uuid":"1050622559","full_name":"abecli/subnet","owner":"abecli","description":"Subnet Calculator Backend (Go)","archived":false,"fork":false,"pushed_at":"2025-11-14T03:32:12.000Z","size":7095,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-12T00:26:11.095Z","etag":null,"topics":["cidr","golang","subnets"],"latest_commit_sha":null,"homepage":"https://subnets.web.app/","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/abecli.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-04T17:35:45.000Z","updated_at":"2025-11-14T03:32:16.000Z","dependencies_parsed_at":"2025-09-23T06:22:00.538Z","dependency_job_id":"31122401-af26-415f-b12c-1ad67734113f","html_url":"https://github.com/abecli/subnet","commit_stats":null,"previous_names":["abe-alt/subnet","abecli/subnet"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/abecli/subnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecli%2Fsubnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecli%2Fsubnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecli%2Fsubnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecli%2Fsubnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abecli","download_url":"https://codeload.github.com/abecli/subnet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abecli%2Fsubnet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28441032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"online","status_checked_at":"2026-01-15T02:00:08.019Z","response_time":62,"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":["cidr","golang","subnets"],"created_at":"2026-01-11T22:46:01.272Z","updated_at":"2026-01-15T02:06:24.783Z","avatar_url":"https://github.com/abecli.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Subnet Calculator Backend (Go)\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Go Reference](https://pkg.go.dev/badge/github.com/Abe-alt/subnet.svg)](https://pkg.go.dev/github.com/Abe-alt/subnet)\n![Go 1.22+](https://img.shields.io/badge/go-1.22%2B-00ADD8?logo=go)\n![Cloud Run](https://img.shields.io/badge/Cloud%20Run-ready-4285F4?logo=google-cloud\u0026logoColor=white)\n![Docker](https://img.shields.io/badge/container-ready-2496ED?logo=docker\u0026logoColor=white)\n\nGo CLI and HTTP API for subnet calculations. Includes a Dockerfile and supports deployment to Cloud Run.\n\n### Live Demo\n- Live demo of the calculator: https://subnets.web.app\n\n### Requirements\n- Go 1.22+\n- Optional: Docker (for container builds)\n- Optional: gcloud CLI (for Cloud Run deploys)\n\n### Quick Start\n- CLI (single calculation):\n  - `cd backend`\n  - `go run . 192.168.1.10/26`\n\n- HTTP server (local):\n  - `cd backend`\n  - `go run . serve :8080`\n  - Then: `curl 'http://localhost:8080/api/subnet?cidr=192.168.1.10/26'`\n\nServer respects `PORT` env (e.g., `PORT=8080 go run . serve`). If a positional port is provided (e.g., `:8080` or `8080`), it overrides the env value.\n\n### API\n- Endpoint: `GET /api/subnet?cidr=\u003cip/prefix\u003e`\n- Query params:\n  - `cidr` (required): IPv4 CIDR like `192.168.1.10/26`\n- Response (JSON):\n  - Subnet details: `address`, `prefix`, `total`, `subnetMask`, `wildcardMask`, `network`, `firstHost`, `lastHost`, `broadcast`, `usableHosts`\n  - Lists of possible addresses:  `networks[]`, `hosts[]`, `broadcasts[]` \nExample:\n\n```\nGET /api/subnet?cidr=192.168.1.10/26\n{\n  \"address\": \"192.168.1.10\",\n  \"prefix\": 26,\n  \"total\": 64,\n  \"subnetMask\": \"255.255.255.192\",\n  \"wildcardMask\": \"0.0.0.63\",\n  \"network\": \"192.168.1.0\",\n  \"firstHost\": \"192.168.1.1\",\n  \"lastHost\": \"192.168.1.62\",\n  \"broadcast\": \"192.168.1.63\",\n  \"usableHosts\": 62,\n  \"networks\": [\"192.168.1.0\", \"192.168.1.64\", \"…\"],\n  \"hosts\": [\"192.168.1.1 - 192.168.1.62\", \"…\"],\n  \"broadcasts\": [\"192.168.1.63\", \"192.168.1.127\", \"…\"]\n}\n```\n\nNotes:\n- Basic CORS is enabled (Access-Control-Allow-Origin: `*`).\n\n### Docker\nBuild a minimal image via multi-stage Dockerfile:\n\n```\ncd backend\ndocker build -t subnet-api .\ndocker run --rm -e PORT=8080 -p 8080:8080 subnet-api\n# Test\ncurl 'http://localhost:8080/api/subnet?cidr=192.168.1.10/26'\n```\n\nThe image uses a distroless runtime and reads the port from `PORT`.\n\n### Cloud Run (container deploy)\nUsing an already built container image:\n\n```\ngcloud builds submit --tag gcr.io/\u003cPROJECT_ID\u003e/subnet-api ./backend\ngcloud run deploy subnet-api \\\n  --image gcr.io/\u003cPROJECT_ID\u003e/subnet-api \\\n  --region us-central1 \\\n  --allow-unauthenticated\n```\n\nSource-based deploy (builds in Cloud Build):\n\n```\ngcloud run deploy subnet-api \\\n  --source ./backend \\\n  --region us-central1 \\\n  --allow-unauthenticated\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabecli%2Fsubnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabecli%2Fsubnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabecli%2Fsubnet/lists"}