mysqlProxy

package
v0.0.0-...-539d32a Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComQuit byte = iota + 1

	ComQuery
	ComFieldList

	ComStmtPrepare
	ComStmtExecute

	ComStmtClose
)

Variables

This section is empty.

Functions

func Max

func Max(x, y int) int

func ScramblePassword

func ScramblePassword(scramble []byte, password string) []byte

Types

type AuthorizationPacket

type AuthorizationPacket struct {
	PacketPart1 []byte
	Username    []byte
	Password    []byte
	CapData     []byte
	CapData2    []byte
	PacketPart2 []byte
	// contains filtered or unexported fields
}

func GetAuthPacket

func GetAuthPacket(conn net.Conn) *AuthorizationPacket

func (*AuthorizationPacket) Decode

func (r *AuthorizationPacket) Decode(conn net.Conn) error

func (AuthorizationPacket) Encode

func (r AuthorizationPacket) Encode() ([]byte, error)

type CapabilityFlag

type CapabilityFlag uint32

func (CapabilityFlag) Has

func (r CapabilityFlag) Has(flag CapabilityFlag) bool

func (CapabilityFlag) String

func (r CapabilityFlag) String() string

type Connection

type Connection struct {
	JmsService *service.JMService
	FakeServer *FakeServer
	Finished   *chan struct{}
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(fakeSrv *FakeServer) *Connection

type CurrSession

type CurrSession struct {
	CreateSessionCallback    func() error
	ConnectedSuccessCallback func() error
	ConnectedFailedCallback  func(err error) error
	DisConnectedCallback     func() error
	SwSess                   *proxy.SwitchSession
	// contains filtered or unexported fields
}

type FakeHandshakePacket

type FakeHandshakePacket struct {
	Protocol                   byte
	Version                    []byte
	ThreadId                   []byte
	Salt                       []byte
	ServerCapabilities         []byte
	ServerLanguage             byte
	ServerStatus               []byte
	ExtendedServerCapabilities []byte
	AuthenticationPluginLength byte
	Unused                     []byte
	Salt2                      []byte
	AuthenticationPlugin       []byte
	// contains filtered or unexported fields
}

func (*FakeHandshakePacket) Encode

func (r *FakeHandshakePacket) Encode() ([]byte, error)

func (*FakeHandshakePacket) IncrementConnectID

func (f *FakeHandshakePacket) IncrementConnectID(curID []byte)

func (*FakeHandshakePacket) NewHandshakePacket

func (r *FakeHandshakePacket) NewHandshakePacket(connID []byte) error

type FakeServer

type FakeServer struct {
	Conn        net.Conn
	JmsService  *service.JMService
	Host        string
	Port        int
	Username    string
	Password    string
	CurrSession *CurrSession
	Token       *service.TokenAuthInfoResponse
}

func (*FakeServer) GetCommandRecorder

func (fs *FakeServer) GetCommandRecorder() *proxy.CommandRecorder

func (*FakeServer) GetRecorders

func (fs *FakeServer) GetRecorders() (*proxy.ReplyRecorder, *proxy.CommandRecorder)

func (*FakeServer) GetReplayRecorder

func (fs *FakeServer) GetReplayRecorder() *proxy.ReplyRecorder

func (*FakeServer) Start

func (fs *FakeServer) Start()

type InitialHandshakePacket

type InitialHandshakePacket struct {
	ProtocolVersion   uint8
	ServerVersion     []byte
	ConnectionId      uint32
	AuthPluginData    []byte
	Filler            byte
	CapabilitiesFlags CapabilityFlag
	CharacterSet      uint8
	StatusFlags       uint16
	AuthPluginDataLen uint8
	AuthPluginName    []byte
	// contains filtered or unexported fields
}

InitialHandshakePacket represents initial handshake packet sent by MySQL Server

func (*InitialHandshakePacket) Decode

func (r *InitialHandshakePacket) Decode(conn net.Conn) error

Decode decodes the first packet received from the MySQl Server It's a handshake packet

func (InitialHandshakePacket) Encode

func (r InitialHandshakePacket) Encode() ([]byte, error)

Encode encodes the InitialHandshakePacket to bytes

func (InitialHandshakePacket) String

func (r InitialHandshakePacket) String() string

type PacketHeader

type PacketHeader struct {
	Length     uint32
	SequenceId uint8
}

PacketHeader represents packet header

type Proxy

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

func NewProxy

func NewProxy(host, port string, ctx context.Context, jmsService *service.JMService) *Proxy

type Request

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

func (*Request) Write

func (req *Request) Write(packet []byte) (n int, err error)

type Response

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

func (*Response) Write

func (res *Response) Write(packet []byte) (n int, err error)

Jump to

Keyboard shortcuts

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