Skip to content

Commit

Permalink
Clean after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
smallinsky authored and greedy52 committed Oct 3, 2024
1 parent 5c82c1f commit 19970e5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Conn struct {
credentialProvider CredentialProvider
user string
password string
db string
cachingSha2FullAuth bool

h Handler
Expand Down Expand Up @@ -71,8 +72,8 @@ func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, err
return c, nil
}

// NewCustomizedConn: create connection with customized server settings
func NewCustomizedConn(conn net.Conn, serverConf *Server, p CredentialProvider, h Handler) (*Conn, error) {
// MakeConn creates a new server side connection without performing the handshake.
func MakeConn(conn net.Conn, serverConf *Server, p CredentialProvider, h Handler) *Conn {
var packetConn *packet.Conn
if serverConf.tlsConfig != nil {
packetConn = packet.NewTLSConn(conn)
Expand All @@ -91,6 +92,13 @@ func NewCustomizedConn(conn net.Conn, serverConf *Server, p CredentialProvider,
}
c.closed.Set(false)

return c
}

// NewCustomizedConn: create connection with customized server settings
func NewCustomizedConn(conn net.Conn, serverConf *Server, p CredentialProvider, h Handler) (*Conn, error) {
c := MakeConn(conn, serverConf, p, h)

if err := c.handshake(); err != nil {
c.Close()
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions server/handshake_resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ func (c *Conn) readDb(data []byte, pos int) (int, error) {
if err := c.h.UseDB(db); err != nil {
return 0, err
}

c.db = db
}
return pos, nil
}
Expand Down
25 changes: 25 additions & 0 deletions server/teleport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package server

import (
. "github.com/go-mysql-org/go-mysql/mysql"
)

func (c *Conn) WriteInitialHandshake() error {
return c.writeInitialHandshake()
}

func (c *Conn) ReadHandshakeResponse() error {
return c.readHandshakeResponse()
}

func (c *Conn) GetDatabase() string {
return c.db
}

func (c *Conn) WriteOK(r *Result) error {
return c.writeOK(r)
}

func (c *Conn) WriteError(e error) error {
return c.writeError(e)
}

0 comments on commit 19970e5

Please sign in to comment.