sqlserver

package
v11.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTestClient

func MakeTestClient(ctx context.Context, config common.TestClientConfig) (*mssql.Conn, error)

MakeTestClient returns SQL Server client used in tests.

Types

type Connector

type Connector interface {
	Connect(context.Context, *common.Session, *protocol.Login7Packet) (io.ReadWriteCloser, []mssql.Token, error)
}

Connector defines an interface for connecting to a SQL Server so it can be swapped out in tests.

type Engine

type Engine struct {
	// EngineConfig is the common database engine configuration.
	common.EngineConfig
	// Connector allows to override SQL Server connection logic. Used in tests.
	Connector Connector
	// contains filtered or unexported fields
}

Engine handles connections from SQL Server clients coming from Teleport proxy over reverse tunnel.

func (*Engine) HandleConnection

func (e *Engine) HandleConnection(ctx context.Context, sessionCtx *common.Session) error

HandleConnection authorizes the incoming client connection, connects to the target SQL Server server and starts proxying messages between client/server.

func (*Engine) InitializeConnection

func (e *Engine) InitializeConnection(clientConn net.Conn, _ *common.Session) error

InitializeConnection initializes the client connection.

func (*Engine) SendError

func (e *Engine) SendError(err error)

SendError sends an error to SQL Server client.

type Proxy

type Proxy struct {
	// Middleware is the auth middleware.
	Middleware *auth.Middleware
	// Service is used to connect to a remote database service.
	Service common.Service
	// Log is used for logging.
	Log logrus.FieldLogger
}

Proxy accepts connections from SQL Server clients, performs a Pre-Login handshake and then forwards the connection to the database service agent.

func (*Proxy) HandleConnection

func (p *Proxy) HandleConnection(ctx context.Context, proxyCtx *common.ProxyContext, conn net.Conn) error

HandleConnection accepts connection from a SQL Server client, authenticates it and proxies it to an appropriate database service.

type TestConnector

type TestConnector struct{}

TestConnector is used in tests to mock connections to SQL Server.

func (*TestConnector) Connect

func (c *TestConnector) Connect(ctx context.Context, sessionCtx *common.Session, loginPacket *protocol.Login7Packet) (io.ReadWriteCloser, []mssql.Token, error)

Connect simulates successful connection to a SQL Server.

type TestServer

type TestServer struct {
	// contains filtered or unexported fields
}

TestServer is a test MSServer server used in functional database access tests.

func NewTestServer

func NewTestServer(config common.TestServerConfig) (svr *TestServer, err error)

NewTestServer returns a new instance of a test MSServer.

func (*TestServer) Close

func (s *TestServer) Close() error

Close closes the server listener.

func (*TestServer) Port

func (s *TestServer) Port() string

Port returns SQL Server port.

func (*TestServer) Serve

func (s *TestServer) Serve() error

Serve starts serving client connections.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL