commit c90cf61f8fabcb90ab2a56309fb0697b71314698 from: Gil Raphaelli via: Dustin Sallings date: Sat Jun 24 04:46:37 2017 UTC enable client creation from an existing connection commit - 5787f144b72abc64a01c267bba5468d4db22b1ff commit + c90cf61f8fabcb90ab2a56309fb0697b71314698 blob - c64ac8c8af19d7f9fe23434e886760a7f0955c01 blob + 95282373aa5fe50714181c3824064e1c35071d36 --- client/client.go +++ client/client.go @@ -24,6 +24,15 @@ func New(net, addr string) (*Client, error) { return nil, err } + return connect(conn) +} + +// NewConn wraps an existing connection, for example one opened with tls.Dial +func NewConn(conn io.ReadWriteCloser) (*Client, error) { + return connect(textproto.NewConn(conn)) +} + +func connect(conn *textproto.Conn) (*Client, error) { _, msg, err := conn.ReadCodeLine(200) if err != nil { return nil, err