docs(proxy): align AX comments

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-05 02:24:39 +00:00
parent f0d5f6ae86
commit f4f0081eb0
2 changed files with 24 additions and 9 deletions

View file

@ -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

View file

@ -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
// }