package ssh import ( "log" "forge.cadoles.com/wpetit/rebound/stat" ) type Options struct { Logger func(message string, args ...any) SockDir string `env:"SOCK_DIR"` PublicPort uint `env:"PUBLIC_PORT"` PublicHost string `env:"PUBLIC_HOST"` HostKey string `env:"HOST_KEY"` Stats *stat.Store } type OptionFunc func(*Options) func DefaultOptions() *Options { return &Options{ SockDir: "./socks", Logger: log.Printf, PublicPort: 2222, PublicHost: "127.0.0.1", HostKey: "./host.key", Stats: stat.NewStore(), } } func WithSockDir(addr string) func(*Options) { return func(opts *Options) { opts.SockDir = addr } } func WithPublicHost(host string) func(*Options) { return func(opts *Options) { opts.PublicHost = host } } func WithPublicPort(port uint) func(*Options) { return func(opts *Options) { opts.PublicPort = port } } func WithHostKey(key string) func(*Options) { return func(opts *Options) { opts.HostKey = key } } func WithLogger(logger func(message string, args ...any)) func(*Options) { return func(opts *Options) { opts.Logger = logger } } func WithStats(stats *stat.Store) func(*Options) { return func(opts *Options) { opts.Stats = stats } }