Documentation ¶
Overview ¶
Package proxy implements client and server code for proxying an unsecure connection over SSL.
Index ¶
- func Dial(instance string) (net.Conn, error)
- func Init(auth *http.Client, connset *ConnSet, dialer Dialer)
- func InitClient(c Client)
- func InitDefault(ctx context.Context) error
- func NewConnSrc(instance string, l net.Listener) <-chan Conn
- type CertSource
- type Client
- type Conn
- type ConnSet
- type Dialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
Dial returns a net.Conn connected to the Cloud SQL Instance specified. The format of 'instance' is "project-name:region:instance-name".
If one of the Init functions hasn't been called yet, InitDefault is called.
This is a network-level function; consider looking in the dialers subdirectory for more convenience functions related to actually logging into your database.
func Init ¶
Init must be called before Dial is called. This is a more flexible version of InitDefault, but allows you to set more fields.
The http.Client is used to authenticate API requests. The connset parameter is optional. If the dialer is nil, net.Conn is used.
func InitClient ¶
func InitClient(c Client)
InitClient is similar to Init, but allows you to specify the Client directly.
func InitDefault ¶
InitDefault attempts to initialize the Dial function using application default credentials.
func NewConnSrc ¶
NewConnSrc returns a chan which can be used to receive connections on the passed Listener. All requests sent to the returned chan will have the instance name provided here. The chan will be closed if the Listener returns an error.
Types ¶
type CertSource ¶
type CertSource interface { // Local returns a certificate that can be used to authenticate with the // provided instance. Local(instance string) (tls.Certificate, error) // Remote returns the instance's CA certificate, address, and name. Remote(instance string) (cert *x509.Certificate, addr, name string, err error) }
CertSource is how a Client obtains various certificates required for operation.
type Client ¶
type Client struct { // Port designates which remote port should be used when connecting to // instances. This value is defined by the server-side code, but for now it // should always be 3307. Port int Certs CertSource Conns *ConnSet // Dialer should return a new connection to the provided address. It is // called on each new connection to an instance. net.Dial will be used if // left nil. Dialer func(net, addr string) (net.Conn, error) // RefreshCfgThrottle is the amount of time to wait between configuration // refreshes. If not set, it defaults to 1 minute. // // This is to prevent quota exhaustion in the case of client-side // malfunction. RefreshCfgThrottle time.Duration // contains filtered or unexported fields }
Client is a type to handle connecting to a Server. All fields are required unless otherwise specified.
type ConnSet ¶
A ConnSet tracks net.Conns associated with a provided ID.
func (*ConnSet) Add ¶
Add saves the provided conn and associates it with the given string identifier.