From f4f0081eb087c6c7fd7284fd66604a09f143a6b1 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sun, 5 Apr 2026 02:24:39 +0000 Subject: [PATCH] docs(proxy): align AX comments Co-Authored-By: Virgil --- config.go | 16 ++++++++++------ proxy.go | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index 681b5bc..1651017 100644 --- a/config.go +++ b/config.go @@ -1,11 +1,12 @@ package proxy -// Config is the top-level proxy configuration used by `proxy.New`. +// Config is the top-level proxy configuration. // // cfg := &proxy.Config{ -// Mode: "nicehash", -// Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, -// Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}, +// Mode: "nicehash", +// Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, +// Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}, +// Watch: true, // Workers: proxy.WorkersByRigID, // } type Config struct { @@ -75,9 +76,12 @@ type HTTPConfig struct { Restricted bool `json:"restricted"` // true = read-only GET only } -// RateLimit controls per-IP connection throttling. +// RateLimit configures per-IP connection throttling. // -// limiter := proxy.NewRateLimiter(proxy.RateLimit{MaxConnectionsPerMinute: 30, BanDurationSeconds: 300}) +// limiter := proxy.NewRateLimiter(proxy.RateLimit{ +// MaxConnectionsPerMinute: 30, +// BanDurationSeconds: 300, +// }) type RateLimit struct { MaxConnectionsPerMinute int `json:"max-connections-per-minute"` // 0 = disabled BanDurationSeconds int `json:"ban-duration"` // 0 = no ban diff --git a/proxy.go b/proxy.go index 66b545c..6f2dc37 100644 --- a/proxy.go +++ b/proxy.go @@ -16,7 +16,12 @@ import ( // Proxy wires the configured listeners, splitters, stats, workers, and log sinks. // -// cfg := &proxy.Config{Mode: "nicehash", Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}, Workers: proxy.WorkersByRigID} +// cfg := &proxy.Config{ +// Mode: "nicehash", +// Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, +// Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}, +// Workers: proxy.WorkersByRigID, +// } // p, result := proxy.New(cfg) // if result.OK { // p.Start() @@ -113,7 +118,10 @@ type CloseEvent struct { // ConfigWatcher polls a config file every second and reloads on modification. // -// watcher := proxy.NewConfigWatcher("config.json", func(cfg *proxy.Config) { p.Reload(cfg) }) +// watcher := proxy.NewConfigWatcher("config.json", func(cfg *proxy.Config) { +// p.Reload(cfg) +// }) +// watcher.Start() type ConfigWatcher struct { path string onChange func(*Config) @@ -125,7 +133,10 @@ type ConfigWatcher struct { // RateLimiter throttles new connections per source IP. // -// limiter := proxy.NewRateLimiter(proxy.RateLimit{MaxConnectionsPerMinute: 30, BanDurationSeconds: 300}) +// limiter := proxy.NewRateLimiter(proxy.RateLimit{ +// MaxConnectionsPerMinute: 30, +// BanDurationSeconds: 300, +// }) // if limiter.Allow("1.2.3.4:3333") { // // accept the socket // }