Open
Description
I propose to add the following callbacks.
// ServerConfig holds server specific configuration data.
type ServerConfig struct {
...
// ConfigForClientCallback, if not nil, is called after receiving the
// version from the client. It may return a non-nil ServerConfig in order to
// change the ServerConfig that will be used to handle this connection. If
// the returned ServerConfig is nil, the original ServerConfig will be used.
// The ServerConfig returned by this callback may not be subsequently
// modified. If an error is returned the handshake will fail.
ConfigForClientCallback func(conn ConnMetadata) (*ServerConfig, error)
}
// A ClientConfig structure is used to configure a Client. It must not be
// modified after having been passed to an SSH function.
type ClientConfig struct {
...
// ConfigForServerCallback, if not nil, is called after receiving the
// version from the server. It may return a non-nil ClientConfig in order to
// change the ClientConfig that will be used to handle this connection. If
// the returned ClientConfig is nil, the original ClientConfig will be used.
// The ClientConfig returned by this callback may not be subsequently
// modified. If an error is returned the handshake will fail.
ConfigForServerCallback func(conn ConnMetadata) (*ClientConfig, error)
These additions enable many advanced use cases, for example we can enable/disable algorithms, authentication methods, banners etc. depending on the client or server version.
cc @golang/security
Metadata
Metadata
Assignees
Type
Projects
Status
Incoming