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

Function NewConn

IceFireDB-SQLProxy/pkg/mysql/server/conn.go:50–79  ·  view source on GitHub ↗

NewConn: create connection with default server settings

(conn net.Conn, user string, password string, h Handler)

Source from the content-addressed store, hash-verified

48
49// NewConn: create connection with default server settings
50func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, error) {
51 p := NewInMemoryProvider()
52 p.AddUser(user, password)
53 salt, _ := RandomBuf(20)
54
55 var packetConn *packet.Conn
56 if defaultServer.tlsConfig != nil {
57 packetConn = packet.NewTLSConn(conn)
58 } else {
59 packetConn = packet.NewConn(conn)
60 }
61
62 c := &Conn{
63 Conn: packetConn,
64 serverConf: defaultServer,
65 credentialProvider: p,
66 h: h,
67 connectionID: atomic.AddUint32(&baseConnID, 1),
68 stmts: make(map[uint32]*Stmt),
69 salt: salt,
70 }
71 c.closed.Set(false)
72
73 if err := c.handshake(); err != nil {
74 c.Close()
75 return nil, err
76 }
77
78 return c, nil
79}
80
81// NewCustomizedConn: create connection with customized server settings
82func NewCustomizedConn(conn net.Conn, serverConf *Server, p CredentialProvider, h Handler) (*Conn, error) {

Callers

nothing calls this directly

Calls 8

AddUserMethod · 0.95
handshakeMethod · 0.95
CloseMethod · 0.95
NewTLSConnFunction · 0.92
NewConnFunction · 0.92
SetMethod · 0.80
NewInMemoryProviderFunction · 0.70
RandomBufFunction · 0.50

Tested by

no test coverage detected