Skip to content

Commit 953b045

Browse files
committed
Move to the full access host instead of the remote addr
The remote addr is only a base address and not the full address. This means clients still build their own hostnames which is what we want to move away from. This changes the internal API and we'll be updating all the dependencies then to switch away from RemoteAddr to this address.
1 parent 33b0d65 commit 953b045

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Diff for: planetscale/certs.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CertificatesService interface {
3131
type Cert struct {
3232
ClientCert tls.Certificate
3333
CACerts []*x509.Certificate
34-
RemoteAddr string
34+
AccessHost string
3535
Ports RemotePorts
3636
}
3737

@@ -103,7 +103,7 @@ func (c *certificatesService) Create(ctx context.Context, r *CreateCertificateRe
103103
var cr struct {
104104
Certificate string `json:"certificate"`
105105
CertificateChain string `json:"certificate_chain"`
106-
RemoteAddr string `json:"remote_addr"`
106+
AccessHost string `json:"access_host"`
107107
Ports map[string]int `json:"ports"`
108108
}
109109

@@ -137,7 +137,7 @@ func (c *certificatesService) Create(ctx context.Context, r *CreateCertificateRe
137137
return &Cert{
138138
ClientCert: clientCert,
139139
CACerts: caCerts,
140-
RemoteAddr: cr.RemoteAddr,
140+
AccessHost: cr.AccessHost,
141141
Ports: RemotePorts{
142142
Proxy: cr.Ports["proxy"],
143143
MySQL: cr.Ports["mysql-tls"],

Diff for: planetscale/certs_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,20 @@ func TestCertificates_Create(t *testing.T) {
8989
pkey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
9090
c.Assert(err, qt.IsNil)
9191

92-
remoteAddr := "foo.example.com"
92+
accessHost := "db.foo.example.com"
9393

9494
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
9595
w.WriteHeader(200)
9696

9797
var out = struct {
9898
Certificate string `json:"certificate"`
9999
CertificateChain string `json:"certificate_chain"`
100-
RemoteAddr string `json:"remote_addr"`
100+
AccessHost string `json:"access_host"`
101101
Ports map[string]int `json:"ports"`
102102
}{
103103
Certificate: testSignedPublicKey,
104104
CertificateChain: testCACert,
105-
RemoteAddr: remoteAddr,
105+
AccessHost: accessHost,
106106
Ports: map[string]int{
107107
"mysql-tls": 3306,
108108
"proxy": 3307,
@@ -126,7 +126,7 @@ func TestCertificates_Create(t *testing.T) {
126126
})
127127
c.Assert(err, qt.IsNil)
128128

129-
c.Assert(cert.RemoteAddr, qt.Equals, remoteAddr)
129+
c.Assert(cert.AccessHost, qt.Equals, accessHost)
130130
c.Assert(cert.CACerts, qt.HasLen, 1)
131131
c.Assert(cert.ClientCert, qt.Not(qt.IsNil))
132132
c.Assert(cert.ClientCert.PrivateKey, qt.Not(qt.IsNil))

0 commit comments

Comments
 (0)