tsnet,client/tailscale: add APIClient which runs API over Noise.

Updates tailscale/corp#4383

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-10-16 13:56:46 -07:00
committed by Maisem Ali
parent e8a11f6181
commit 630bcb5b67
3 changed files with 60 additions and 0 deletions

View File

@@ -3736,6 +3736,20 @@ func (b *LocalBackend) magicConn() (*magicsock.Conn, error) {
return mc, nil
}
type noiseRoundTripper struct {
*LocalBackend
}
func (n noiseRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return n.LocalBackend.DoNoiseRequest(req)
}
// NoiseRoundTripper returns an http.RoundTripper that uses the LocalBackend's
// DoNoiseRequest method.
func (b *LocalBackend) NoiseRoundTripper() http.RoundTripper {
return noiseRoundTripper{b}
}
// DoNoiseRequest sends a request to URL over the control plane
// Noise connection.
func (b *LocalBackend) DoNoiseRequest(req *http.Request) (*http.Response, error) {