package ssh

import (
	

	gossh 
)

// PasswordAuth returns a functional option that sets PasswordHandler on the server.
func ( PasswordHandler) Option {
	return func( *Server) error {
		.PasswordHandler = 
		return nil
	}
}

// PublicKeyAuth returns a functional option that sets PublicKeyHandler on the server.
func ( PublicKeyHandler) Option {
	return func( *Server) error {
		.PublicKeyHandler = 
		return nil
	}
}

// HostKeyFile returns a functional option that adds HostSigners to the server
// from a PEM file at filepath.
func ( string) Option {
	return func( *Server) error {
		,  := os.ReadFile()
		if  != nil {
			return 
		}

		,  := gossh.ParsePrivateKey()
		if  != nil {
			return 
		}

		.AddHostKey()

		return nil
	}
}

func ( KeyboardInteractiveHandler) Option {
	return func( *Server) error {
		.KeyboardInteractiveHandler = 
		return nil
	}
}

// HostKeyPEM returns a functional option that adds HostSigners to the server
// from a PEM file as bytes.
func ( []byte) Option {
	return func( *Server) error {
		,  := gossh.ParsePrivateKey()
		if  != nil {
			return 
		}

		.AddHostKey()

		return nil
	}
}

// NoPty returns a functional option that sets PtyCallback to return false,
// denying PTY requests.
func () Option {
	return func( *Server) error {
		.PtyCallback = func(Context, Pty) bool {
			return false
		}
		return nil
	}
}

// WrapConn returns a functional option that sets ConnCallback on the server.
func ( ConnCallback) Option {
	return func( *Server) error {
		.ConnCallback = 
		return nil
	}
}

var contextKeyEmulatePty = &contextKey{"emulate-pty"}

func emulatePtyHandler( Context,  Session,  Pty) (func() error, error) {
	.SetValue(contextKeyEmulatePty, true)
	return func() error { return nil }, nil
}

// EmulatePty returns a functional option that fakes a PTY. It uses PtyWriter
// underneath.
func () Option {
	return func( *Server) error {
		.PtyHandler = emulatePtyHandler
		return nil
	}
}

// AllocatePty returns a functional option that allocates a PTY. Implementers
// who wish to use an actual PTY should use this along with the platform
// specific PTY implementation defined in pty_*.go.
func () Option {
	return func( *Server) error {
		.PtyHandler = func( Context,  Session,  Pty) (func() error, error) {
			return .(*session).ptyAllocate(.Term, .Window, .Modes)
		}
		return nil
	}
}