rebound/ssh/options.go

54 lines
1.0 KiB
Go

package ssh
import "log"
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"`
}
type OptionFunc func(*Options)
func DefaultOptions() *Options {
return &Options{
SockDir: "./socks",
Logger: log.Printf,
PublicPort: 2222,
PublicHost: "127.0.0.1",
HostKey: "./host.key",
}
}
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
}
}