Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUserNotFound — the username from HandshakeResponse41 has no DBBat user. ErrUserNotFound = errors.New("user not found") // ErrServerNotFound — no DBBat database matches the requested schema name. ErrServerNotFound = errors.New("database not found") // ErrNoActiveGrant — the user has no current grant on the requested database. ErrNoActiveGrant = errors.New("no active grant") // ErrInvalidPassword — the supplied password failed Argon2id verification. ErrInvalidPassword = errors.New("invalid password") // ErrUnsupportedAuthPlugin — auth provider was asked for a plugin we don't implement. ErrUnsupportedAuthPlugin = errors.New("unsupported authentication plugin") // ErrSSLNotSupported — client sent SSL Request; v1 only supports plaintext. ErrSSLNotSupported = errors.New("TLS connections not supported by this proxy") // ErrUpstreamConnect — outbound connection to the upstream MySQL failed. ErrUpstreamConnect = errors.New("upstream connection failed") // ErrCommandNotPermitted — protocol-level command refused (admin/replication). ErrCommandNotPermitted = errors.New("command not permitted through dbbat") // ErrSwitchDatabaseDenied — COM_INIT_DB tried to change the session database. ErrSwitchDatabaseDenied = errors.New("switching database not permitted through dbbat") // ErrAPIKeyOwnerMismatch — the API key authenticates a different user than the handshake claimed. ErrAPIKeyOwnerMismatch = errors.New("API key does not belong to authenticating user") // ErrQueryLimitExceeded — the grant's max_query_count quota has been reached. ErrQueryLimitExceeded = errors.New("query count limit exceeded for this grant") // ErrDataLimitExceeded — the grant's max_bytes_transferred quota has been reached. ErrDataLimitExceeded = errors.New("data transfer limit exceeded for this grant") // ErrCachingSha2NeedsRSA — non-TLS caching_sha2 client tried full auth but no RSA key is configured. ErrCachingSha2NeedsRSA = errors.New("non-TLS caching_sha2_password requires an RSA key (configure mysql.tls or send password over TLS)") // ErrSaltFieldMissing — go-mysql library moved or removed the unexported Conn.salt field; readConnSalt cannot proceed. ErrSaltFieldMissing = errors.New("go-mysql Conn.salt field not found (library version mismatch?)") // ErrSaltFieldUnexpectedType — go-mysql library changed Conn.salt to a non-[]byte type. ErrSaltFieldUnexpectedType = errors.New("go-mysql Conn.salt field has unexpected type") )
Sentinel errors for the MySQL proxy session lifecycle.
var ErrTLSConfigInvalid = errors.New("mysql tls: cert_file and key_file must both be set or both empty")
ErrTLSConfigInvalid is returned when only one of cert/key files is set.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the MySQL proxy server. It accepts MySQL client connections, authenticates them against the DBBat user store, and proxies commands to the upstream MySQL database configured for the requested schema.
func NewServer ¶
func NewServer( dataStore *store.Store, encryptionKey []byte, queryStorage config.QueryStorageConfig, dumpConfig config.DumpConfig, authCache *cache.AuthCache, mysqlConfig config.MySQLConfig, logger *slog.Logger, ) (*Server, error)
NewServer creates a new MySQL proxy server.
func (*Server) Addr ¶
Addr returns the listener's bound address, or nil if the server has not started accepting connections yet. Useful in tests that pass ":0" for the listen address and need to discover the OS-assigned port.
func (*Server) SetApprovalDeps ¶ added in v0.20.0
func (s *Server) SetApprovalDeps(deps shared.ApprovalDeps)
SetApprovalDeps installs the approval-hold collaborators. A server without them never holds anything.
func (*Server) SetRowWriter ¶ added in v0.20.0
SetRowWriter installs the process-wide result-row writer, replacing (and shutting down) the private one NewServer created. Batching across every protocol is where the design pays off most: a busy proxy with many small result sets then issues one INSERT per ~1000 rows overall rather than one per query.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a single client connection through the MySQL proxy.
func (*Session) KillHeldQuery ¶ added in v0.20.0
KillHeldQuery ends a statement parked on a human in response to a MySQL KILL QUERY. Reports whether anything was parked.