MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / Validate

Method Validate

config/sshproxy.go:50–76  ·  view source on GitHub ↗

Validate checks the configuration for the backing SSH server.

()

Source from the content-addressed store, hash-verified

48
49// Validate checks the configuration for the backing SSH server.
50func (c SSHProxyConfig) Validate() error {
51 if c.Server == "" {
52 return newError("server", "server cannot be empty")
53 }
54 if c.Username == "" && !c.UsernamePassThrough {
55 return newError("username", "username cannot be empty when usernamePassThrough is not set")
56 }
57 if len(c.AllowedHostKeyFingerprints) == 0 {
58 return newError("allowedHostKeyFingerprints", "allowedHostKeyFingerprints cannot be empty")
59 }
60 if err := c.Ciphers.Validate(); err != nil {
61 return wrap(err, "ciphers")
62 }
63 if err := c.KexAlgorithms.Validate(); err != nil {
64 return wrap(err, "kex")
65 }
66 if err := c.MACs.Validate(); err != nil {
67 return wrap(err, "macs")
68 }
69 if err := c.HostKeyAlgorithms.Validate(); err != nil {
70 return wrap(err, "hostKeyAlgos")
71 }
72 if err := c.ClientVersion.Validate(); err != nil {
73 return wrap(err, "clientVersion")
74 }
75 return nil
76}
77
78func (c SSHProxyConfig) LoadPrivateKey() (ssh.Signer, error) {
79 if c.PrivateKey == "" {

Callers

nothing calls this directly

Calls 3

newErrorFunction · 0.85
wrapFunction · 0.85
ValidateMethod · 0.65

Tested by

no test coverage detected