Documentation
¶
Overview ¶
Package mysqlproxy serves an app's mysql.sock. It speaks just enough of the MySQL protocol to greet the app without asking for credentials, log in upstream as the app's own database user, and relay the session through a command allow-list. Runners import it; apps do not.
Index ¶
Constants ¶
const MaxConns = 32
MaxConns is how many database connections one app may have open through its proxy.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proxy ¶
type Proxy struct {
// OnError, if set, gets the reason the proxy could not open the app's database. Errors
// never carry the password. It may be called from several goroutines at once.
OnError func(error)
// contains filtered or unexported fields
}
Proxy serves one app's mysql.sock. It greets the app without asking for credentials, logs in upstream as the app's own database user and relays the session.
func (*Proxy) Close ¶
func (p *Proxy) Close()
Close ends every open session and waits for them to stop. Close the listener first.
func (*Proxy) Serve ¶
Serve accepts the app's connections on l until l is closed. A connection over MaxConns gets E-SQL-004 and is closed.
func (*Proxy) SetUpstream ¶
SetUpstream makes the proxy log in as up from the next connection it accepts on. Sessions already open keep the login they have.