MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / New

Function New

internal/sshserver/New.go:11–32  ·  view source on GitHub ↗

New creates a new SSH server ready to be run. It may return an error if the configuration is invalid.

(cfg config.SSHConfig, handler Handler, logger log.Logger)

Source from the content-addressed store, hash-verified

9
10// New creates a new SSH server ready to be run. It may return an error if the configuration is invalid.
11func New(cfg config.SSHConfig, handler Handler, logger log.Logger) (Server, error) {
12 if err := cfg.Validate(); err != nil {
13 return nil, err
14 }
15 hostKeys, err := cfg.LoadHostKeys()
16 if err != nil {
17 return nil, err
18 }
19 return &serverImpl{
20 cfg: cfg,
21 handler: handler,
22 logger: logger,
23 wg: &sync.WaitGroup{},
24 lock: &sync.Mutex{},
25 listenSocket: nil,
26 hostKeys: hostKeys,
27 shutdownHandlers: &shutdownRegistry{
28 lock: &sync.Mutex{},
29 callbacks: map[string]shutdownHandler{},
30 },
31 }, nil
32}

Callers 6

createSSHServerFunction · 0.92
TestReadyRejectionFunction · 0.92
startMethod · 0.92
startSSHServerFunction · 0.92
NewTestServerFunction · 0.70

Calls 2

LoadHostKeysMethod · 0.80
ValidateMethod · 0.65

Tested by 4

TestReadyRejectionFunction · 0.74
startMethod · 0.74
startSSHServerFunction · 0.74