Rewrite SilkRouter as a dependency-free, cross-platform Go binary#1
Draft
serainox420 wants to merge 1 commit into
Draft
Rewrite SilkRouter as a dependency-free, cross-platform Go binary#1serainox420 wants to merge 1 commit into
serainox420 wants to merge 1 commit into
Conversation
Port the bash toolkit (px.sh, blcheck.sh, proxycheck.sh) into one static, cross-platform Go binary (Linux/Windows/macOS, amd64/arm64) built with CGO_ENABLED=0 and the standard library only — no go.sum, no runtime deps. Highlights - Native dialers for http, https, socks4, socks4a and socks5, hand-rolled over the standard library (incl. SOCKS4/4a, which x/net/proxy lacks). - Pluggable caching probes: nine built-ins (cloudflare, google, gstatic, msft, apple, example, ipify, aws, icanhazip) plus custom -test-url, so validation is no longer hard-wired to Cloudflare. Adding one is a one-line registry entry. - Descriptive error handling across dialing, handshakes, fetching, probing and cache building; the builder never overwrites a good cache with an empty result. - Consolidated proxy list embedded via go:embed for offline builds (-builtin). - Subcommands: build, recache, list, route, check, blcheck, proxycheck, probes, version. Layout - internal/proxy Proxy type, parsing, dialers/transport - internal/probe caching probes (registry) - internal/source candidate lists (url/file/embedded) - internal/cache concurrent build, merge, load, save, report - internal/router proxy selection + command execution - internal/scan blcheck + proxycheck HTML scrapers - internal/ui cross-platform colour handling Tests cover the parser and exercise all four dial paths and the concurrent build pipeline against in-process mock proxy servers. Original shell scripts preserved under legacy/. New README.md and Makefile (build/install/test/release/update) added. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M4KGZH66trVJ6CiEZUGrxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full rewrite of the SilkRouter bash toolkit (
px.sh,blcheck.sh,proxycheck.sh) into a single, dependency-free, cross-platform Go binary. Built withCGO_ENABLED=0and the standard library only (nogo.sum, no external modules), it cross-compiles to Linux, Windows and macOS on amd64/arm64 and needs nocurl/awk/shufat runtime.All three scripts' logic is combined into one subcommand-driven executable, structured for easy future extension.
What's included
Native proxy dialers for every protocol —
http,https,socks4,socks4a,socks5— hand-rolled over the standard library (internal/proxy). SOCKS4/4a are implemented from scratch since Go'sx/net/proxydoesn't cover them. UnifiedDial/Transporthandling so adding a protocol means one switch arm + a handshake.More ways to cache a proxy than Cloudflare — validation is now a pluggable probe registry (
internal/probe) with nine built-ins:cloudflare(default),google,gstatic,msft,apple,example,ipify,aws,icanhazip— plus-test-urlfor a custom endpoint. Adding a new probe is a one-lineregister(...).Error handling across the whole flow — every dial, handshake, fetch and probe returns a descriptive error; the cache builder reports precise per-proxy failure reasons and refuses to overwrite a good cache with an empty result.
Offline capability — the consolidated proxy list is embedded via
go:embed(-builtin).Subcommands:
build,recache,list,route,check,blcheck,proxycheck,probes,version. Cache file format stays compatible with the old tool.Layout
Testing
go test ./...— parser table tests, and integration tests that exercise all four dial paths (SOCKS5, SOCKS4, HTTP forward-GET, HTTP CONNECT) and the concurrent build pipeline against in-process mock proxy servers.go vet ./...andgofmtclean.ldd→ "not a dynamic executable").make check(fmt-check + vet + test) passes; race detector passes viamake test-race.Docs & tooling
README.mddocumenting every subcommand, flag, probe and the package layout.Makefile:build,install,run,test,test-race,check,release(cross-compile matrix),update,clean.🤖 Generated with Claude Code
Generated by Claude Code