From 65405174f342f22bf0799790f652a89a29f2afbf Mon Sep 17 00:00:00 2001 From: Uditha Atukorala Date: Wed, 21 Jan 2026 18:09:38 +0000 Subject: [PATCH] client: option to set local name with starttls --- client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client.go b/client.go index 21d265cf..e2226ed2 100644 --- a/client.go +++ b/client.go @@ -127,6 +127,22 @@ func NewClientStartTLS(conn net.Conn, tlsConfig *tls.Config) (*Client, error) { return c, nil } +// NewClientStartTLSWithLocalName is same as NewClientStartTLS, with the option to provide +// a client identifier (local name) to when initiating the connection. +func NewClientStartTLSWithLocalName(conn net.Conn, tlsConfig *tls.Config, localName string) (*Client, error) { + if err := validateLine(localName); err != nil { + return nil, err + } + + c := NewClient(conn) + c.localName = localName + if err := initStartTLS(c, tlsConfig); err != nil { + c.Close() + return nil, err + } + return c, nil +} + func initStartTLS(c *Client, tlsConfig *tls.Config) error { if err := c.hello(); err != nil { return err