ssh.go

 1package config
 2
 3import (
 4	"strconv"
 5)
 6
 7// SSHConfig is the configuration for the SSH server.
 8type SSHConfig struct {
 9	// ListenAddr is the address on which the SSH server will listen.
10	ListenAddr string `env:"LISTEN_ADDR" yaml:"listen_addr"`
11
12	// PublicURL is the public URL of the SSH server.
13	PublicURL string `env:"PUBLIC_URL" yaml:"public_url"`
14
15	// KeyPath is the path to the SSH server's private key.
16	KeyPath string `env:"KEY_PATH" yaml:"key_path"`
17
18	// ClientKeyPath is the path to the server's client private key.
19	ClientKeyPath string `env:"CLIENT_KEY_PATH" yaml:"client_key_path"`
20
21	// MaxTimeout is the maximum number of seconds a connection can take.
22	MaxTimeout int `env:"MAX_TIMEOUT" yaml:"max_timeout"`
23
24	// IdleTimeout is the number of seconds a connection can be idle before it is closed.
25	IdleTimeout int `env:"IDLE_TIMEOUT" yaml:"idle_timeout"`
26}
27
28// Environ returns the environment variables for the config.
29func (s SSHConfig) Environ() []string {
30	return []string{
31		"SOFT_SERVE_SSH_LISTEN_ADDR=" + s.ListenAddr,
32		"SOFT_SERVE_SSH_PUBLIC_URL=" + s.PublicURL,
33		"SOFT_SERVE_SSH_KEY_PATH=" + s.KeyPath,
34		"SOFT_SERVE_SSH_CLIENT_KEY_PATH=" + s.ClientKeyPath,
35		"SOFT_SERVE_SSH_MAX_TIMEOUT=" + strconv.Itoa(s.MaxTimeout),
36		"SOFT_SERVE_SSH_IDLE_TIMEOUT=" + strconv.Itoa(s.IdleTimeout),
37	}
38}