Skip to content

Commit d2d72ea

Browse files
committed
server: Rework NewConn/defaultServer
1 parent 639eccd commit d2d72ea

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

server/conn.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,9 @@ var baseConnID uint32 = 10000
4242
func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, error) {
4343
p := NewInMemoryProvider()
4444
p.AddUser(user, password)
45+
server := NewDefaultServer()
4546

46-
var packetConn *packet.Conn
47-
if defaultServer.tlsConfig != nil {
48-
packetConn = packet.NewTLSConn(conn)
49-
} else {
50-
packetConn = packet.NewConn(conn)
51-
}
52-
53-
c := &Conn{
54-
Conn: packetConn,
55-
serverConf: defaultServer,
56-
credentialProvider: p,
57-
h: h,
58-
connectionID: atomic.AddUint32(&baseConnID, 1),
59-
stmts: make(map[uint32]*Stmt),
60-
salt: mysql.RandomBuf(20),
61-
}
62-
c.closed.Store(false)
63-
64-
if err := c.handshake(); err != nil {
65-
c.Close()
66-
return nil, err
67-
}
68-
69-
return c, nil
47+
return NewCustomizedConn(conn, server, p, h)
7048
}
7149

7250
// NewCustomizedConn: create connection with customized server settings

server/server_conf.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"github.com/go-mysql-org/go-mysql/mysql"
99
)
1010

11-
var defaultServer = NewDefaultServer()
12-
1311
// Defines a basic MySQL server with configs.
1412
//
1513
// We do not aim at implementing the whole MySQL connection suite to have the best compatibilities for the clients.

0 commit comments

Comments
 (0)