MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / NewClientConn

Function NewClientConn

IceFireDB-SQLite/pkg/mysql/server/conn.go:111–136  ·  view source on GitHub ↗

NewClientConn: create connection with customized server settings

(conn net.Conn, serverConf *Server, p CredentialProvider, hp Handler)

Source from the content-addressed store, hash-verified

109
110// NewClientConn: create connection with customized server settings
111func NewClientConn(conn net.Conn, serverConf *Server, p CredentialProvider, hp Handler) (*Conn, error) {
112 var packetConn *packet.Conn
113 if serverConf.tlsConfig != nil {
114 packetConn = packet.NewTLSConn(conn)
115 } else {
116 packetConn = packet.NewConn(conn)
117 }
118
119 salt, _ := RandomBuf(20)
120 c := &Conn{
121 Conn: packetConn,
122 serverConf: serverConf,
123 h: hp,
124 credentialProvider: p,
125 connectionID: atomic.AddUint32(&baseConnID, 1),
126 stmts: make(map[uint32]*Stmt),
127 salt: salt,
128 }
129 c.closed.Set(false)
130 if err := c.handshake(); err != nil {
131 c.Close()
132 return nil, err
133 }
134
135 return c, nil
136}
137
138func (c *Conn) Handshake(hp Handler) error {
139 c.h = hp

Callers 1

onConnMethod · 0.92

Calls 6

handshakeMethod · 0.95
CloseMethod · 0.95
NewTLSConnFunction · 0.92
NewConnFunction · 0.92
SetMethod · 0.80
RandomBufFunction · 0.50

Tested by

no test coverage detected