{"id":49699265,"url":"https://github.com/mc256/honkai-rule-server","last_synced_at":"2026-05-18T07:13:21.074Z","repository":{"id":356450397,"uuid":"1232485863","full_name":"mc256/honkai-rule-server","owner":"mc256","description":"Self-hosted Mihomo/Clash subscription aggregator: merges multiple upstream sources, applies custom routing rules, and serves a unified config to clients.","archived":false,"fork":false,"pushed_at":"2026-05-08T05:19:30.000Z","size":836,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-08T06:31:18.476Z","etag":null,"topics":["clash","go","kubernetes","mihomo","subscription-aggregator"],"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/mc256.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":"2026-05-08T01:28:27.000Z","updated_at":"2026-05-08T05:18:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mc256/honkai-rule-server","commit_stats":null,"previous_names":["mc256/honkai-rule-server"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/mc256/honkai-rule-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mc256%2Fhonkai-rule-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mc256%2Fhonkai-rule-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mc256%2Fhonkai-rule-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mc256%2Fhonkai-rule-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mc256","download_url":"https://codeload.github.com/mc256/honkai-rule-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mc256%2Fhonkai-rule-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33168910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T05:43:36.989Z","status":"ssl_error","status_checked_at":"2026-05-18T05:43:19.133Z","response_time":71,"last_error":"SSL_read: 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":["clash","go","kubernetes","mihomo","subscription-aggregator"],"created_at":"2026-05-08T06:24:30.398Z","updated_at":"2026-05-18T07:13:21.069Z","avatar_url":"https://github.com/mc256.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# honkai-rule-server\n\nA small Go service that aggregates multiple Mihomo / Clash subscription URLs into a single token-authenticated subscription endpoint. Adds operator-declared own-proxies, exposes aggregated traffic quota in the standard `Subscription-Userinfo` header, and reports a per-source-weighted daily allowance via `/health`.\n\n## Documentation\n\n- **Spec**: [`specs/001-subscription-aggregator/spec.md`](specs/001-subscription-aggregator/spec.md) — what this service does and why\n- **Plan**: [`specs/001-subscription-aggregator/plan.md`](specs/001-subscription-aggregator/plan.md) — tech stack, project layout, test plan\n- **Quickstart**: [`specs/001-subscription-aggregator/quickstart.md`](specs/001-subscription-aggregator/quickstart.md) — go from zero to a running merged subscription\n- **Tasks**: [`specs/001-subscription-aggregator/tasks.md`](specs/001-subscription-aggregator/tasks.md) — implementation task list\n- **Constitution**: [`.specify/memory/constitution.md`](.specify/memory/constitution.md) — non-negotiable engineering principles for this repo\n\n## Layout\n\n```\ncmd/server/         entry point\ninternal/\n  clock/            Clock interface (RealClock + FakeClock for deterministic tests)\n  config/           subscriptions CSV / own-proxies YAML / tokens JSON / server env loaders\n  fetcher/          per-source background fetch + cache + bootstrap state machine\n  merge/            pure-functional transformation core (proxies, proxy-groups, rules, traffic)\n  output/           subscription-mode adapter (renders the served Clash YAML)\n  observability/    log/slog + token sanitization\n  server/           net/http app + auth middleware + routes\n  integration/      cross-package integration + snapshot tests\ntemplates/          served-config template (Clash globals)\nconfig/             operator config (gitignored — see config/README.md)\ndeploy/k8s/         Kubernetes manifests\nexample/            sandbox / sample inputs (NOT imported by the server)\n```\n\n## Build \u0026 test\n\n```bash\nmake build           # → bin/server\nmake test            # all tests\nmake test-race       # all tests + race detector\nmake snapshot-update # accept new committed snapshot baselines (requires PR review)\nmake check           # CI gate: vet + lint + test + verify clean working tree\n```\n\nSee the [quickstart](specs/001-subscription-aggregator/quickstart.md) for end-to-end run instructions.\n\n## Run locally\n\n```bash\n# Copy fixtures as a starting point\ncp internal/integration/testdata/fixtures/subscriptions.csv config/\ncp internal/integration/testdata/fixtures/own-proxies.yaml  config/\ncp internal/integration/testdata/fixtures/tokens.json       config/\n# Edit config/subscriptions.csv to point at your real upstream URLs.\n\nmake build\nSUBSCRIPTIONS_CSV_PATH=./config/subscriptions.csv \\\nOWN_PROXIES_YAML_PATH=./config/own-proxies.yaml \\\nTOKENS_PATH=./config/tokens.json \\\nSERVED_CONFIG_TEMPLATE_PATH=./templates/served-config.template.yaml \\\nCACHE_DIR=./.cache PORT=8080 LOG_LEVEL=info \\\n./bin/server\n```\n\nThen `curl 'http://localhost:8080/?token=\u003ctoken-from-tokens.json\u003e'` returns the merged Clash YAML.\n\nSee the [quickstart](specs/001-subscription-aggregator/quickstart.md) for the full operator workflow including K8s deployment.\n\n## Deployment (Kubernetes)\n\nManifests under [`deploy/k8s/`](deploy/k8s/):\n\n```bash\n# 1. Stuff the three secret-bearing files into a Secret\nkubectl create secret generic honkai-rule-server-config \\\n  --from-file=subscriptions.csv=./config/subscriptions.csv \\\n  --from-file=own-proxies.yaml=./config/own-proxies.yaml \\\n  --from-file=tokens.json=./config/tokens.json\n\n# 2. Apply manifests\nkubectl apply -f deploy/k8s/configmap-served-template.yaml\nkubectl apply -f deploy/k8s/deployment.yaml\nkubectl apply -f deploy/k8s/service.yaml\nkubectl apply -f deploy/k8s/ingress.yaml   # edit hostname first\n```\n\nThe Ingress handles TLS termination per FR-019c. **Only `/` is exposed** to the public internet; `/health` is intentionally omitted (it leaks per-upstream state). Hit `/health` from the cluster-internal Service.\n\n## Constitution + spec coverage\n\n- All 5 Constitution principles (Unified Transformation Core, Deterministic Transformation, CSV strict-schema/loud-failure, Test-First/Real-Input Integration, Observable Routing \u0026 Source-Merge Decisions) — gates pass; see plan.md Constitution Check.\n- All 27 functional requirements (FR-001..FR-019c) and 15 success criteria (SC-001..SC-015) implemented and tested. See [`specs/001-subscription-aggregator/spec.md`](specs/001-subscription-aggregator/spec.md).\n- Three deterministic snapshots committed under `internal/integration/testdata/snapshots/` pin the served-config body, the `Subscription-Userinfo` wire format, and the `/health` JSON response shape (Constitution Principle II).\n\n## Module path\n\nThe committed `go.mod` uses a placeholder owner (`github.com/junlinchen/honkai-rule-server`). After creating the actual GitHub repo, run:\n\n```bash\ngo mod edit -module github.com/\u003cyour-org\u003e/honkai-rule-server\ngo mod tidy\ngoimports -w .   # update import paths in any code that referenced the old path\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmc256%2Fhonkai-rule-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmc256%2Fhonkai-rule-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmc256%2Fhonkai-rule-server/lists"}