diff --git a/ssh.go b/ssh.go index a659ba5..2d7ac00 100644 --- a/ssh.go +++ b/ssh.go @@ -98,14 +98,14 @@ func Serve(l net.Listener, handler Handler, options ...Option) (*Server, error) // ListenAndServe listens on the TCP network address addr and then calls Serve // with handler to handle sessions on incoming connections. Handler is typically // nil, in which case the DefaultHandler is used. -func ListenAndServe(addr string, handler Handler, options ...Option) error { +func ListenAndServe(addr string, handler Handler, options ...Option) (*Server, error) { srv := &Server{Addr: addr, Handler: handler} for _, option := range options { if err := srv.SetOption(option); err != nil { - return err + return nil, err } } - return srv.ListenAndServe() + return srv, srv.ListenAndServe() } // Handle registers the handler as the DefaultHandler.