Skip to content

Commit 43446bc

Browse files
committed
TUN-8423: Deprecate older legacy tunnel capnp interfaces
Since legacy tunnels have been removed for a while now, we can remove many of the capnp rpc interfaces that are no longer leveraged by the legacy tunnel registration and authentication mechanisms.
1 parent e9f0101 commit 43446bc

25 files changed

+1891
-2791
lines changed

cmd/cloudflared/tunnel/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,9 @@ func tunnelFlags(shouldHide bool) []cli.Flag {
663663
}),
664664
altsrc.NewStringSliceFlag(&cli.StringSliceFlag{
665665
Name: "tag",
666-
Usage: "Custom tags used to identify this tunnel, in format `KEY=VALUE`. Multiple tags may be specified",
666+
Usage: "Custom tags used to identify this tunnel via added HTTP request headers to the origin, in format `KEY=VALUE`. Multiple tags may be specified.",
667667
EnvVars: []string{"TUNNEL_TAG"},
668-
Hidden: shouldHide,
668+
Hidden: true,
669669
}),
670670
altsrc.NewDurationFlag(&cli.DurationFlag{
671671
Name: "heartbeat-interval",

cmd/cloudflared/tunnel/configuration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/cloudflare/cloudflared/orchestration"
2828
"github.com/cloudflare/cloudflared/supervisor"
2929
"github.com/cloudflare/cloudflared/tlsconfig"
30-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
30+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
3131
)
3232

3333
const (
@@ -133,7 +133,7 @@ func prepareTunnelConfig(
133133
log.Err(err).Msg("Tag parse failure")
134134
return nil, nil, errors.Wrap(err, "Tag parse failure")
135135
}
136-
tags = append(tags, tunnelpogs.Tag{Name: "ID", Value: clientID.String()})
136+
tags = append(tags, pogs.Tag{Name: "ID", Value: clientID.String()})
137137

138138
transportProtocol := c.String("protocol")
139139

@@ -166,7 +166,7 @@ func prepareTunnelConfig(
166166
)
167167
}
168168

169-
namedTunnel.Client = tunnelpogs.ClientInfo{
169+
namedTunnel.Client = pogs.ClientInfo{
170170
ClientID: clientID[:],
171171
Features: clientFeatures,
172172
Version: info.Version(),

cmd/cloudflared/tunnel/tag.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import (
44
"fmt"
55
"regexp"
66

7-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
7+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
88
)
99

1010
// Restrict key names to characters allowed in an HTTP header name.
1111
// Restrict key values to printable characters (what is recognised as data in an HTTP header value).
1212
var tagRegexp = regexp.MustCompile("^([a-zA-Z0-9!#$%&'*+\\-.^_`|~]+)=([[:print:]]+)$")
1313

14-
func NewTagFromCLI(compoundTag string) (tunnelpogs.Tag, bool) {
14+
func NewTagFromCLI(compoundTag string) (pogs.Tag, bool) {
1515
matches := tagRegexp.FindStringSubmatch(compoundTag)
1616
if len(matches) == 0 {
17-
return tunnelpogs.Tag{}, false
17+
return pogs.Tag{}, false
1818
}
19-
return tunnelpogs.Tag{Name: matches[1], Value: matches[2]}, true
19+
return pogs.Tag{Name: matches[1], Value: matches[2]}, true
2020
}
2121

22-
func NewTagSliceFromCLI(tags []string) ([]tunnelpogs.Tag, error) {
23-
var tagSlice []tunnelpogs.Tag
22+
func NewTagSliceFromCLI(tags []string) ([]pogs.Tag, error) {
23+
var tagSlice []pogs.Tag
2424
for _, compoundTag := range tags {
2525
if tag, ok := NewTagFromCLI(compoundTag); ok {
2626
tagSlice = append(tagSlice, tag)

cmd/cloudflared/tunnel/tag_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ package tunnel
33
import (
44
"testing"
55

6-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
6+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
77

88
"github.com/stretchr/testify/assert"
99
)
1010

1111
func TestSingleTag(t *testing.T) {
1212
testCases := []struct {
1313
Input string
14-
Output tunnelpogs.Tag
14+
Output pogs.Tag
1515
Fail bool
1616
}{
17-
{Input: "x=y", Output: tunnelpogs.Tag{Name: "x", Value: "y"}},
18-
{Input: "More-Complex=Tag Values", Output: tunnelpogs.Tag{Name: "More-Complex", Value: "Tag Values"}},
19-
{Input: "First=Equals=Wins", Output: tunnelpogs.Tag{Name: "First", Value: "Equals=Wins"}},
17+
{Input: "x=y", Output: pogs.Tag{Name: "x", Value: "y"}},
18+
{Input: "More-Complex=Tag Values", Output: pogs.Tag{Name: "More-Complex", Value: "Tag Values"}},
19+
{Input: "First=Equals=Wins", Output: pogs.Tag{Name: "First", Value: "Equals=Wins"}},
2020
{Input: "x=", Fail: true},
2121
{Input: "=y", Fail: true},
2222
{Input: "=", Fail: true},

connection/rpc.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,6 @@ import (
1212
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
1313
)
1414

15-
type tunnelServerClient struct {
16-
client tunnelpogs.TunnelServer_PogsClient
17-
transport rpc.Transport
18-
}
19-
20-
// NewTunnelRPCClient creates and returns a new RPC client, which will communicate using a stream on the given muxer.
21-
// This method is exported for supervisor to call Authenticate RPC
22-
func NewTunnelServerClient(
23-
ctx context.Context,
24-
stream io.ReadWriteCloser,
25-
log *zerolog.Logger,
26-
) *tunnelServerClient {
27-
transport := rpc.StreamTransport(stream)
28-
conn := rpc.NewConn(transport)
29-
registrationClient := tunnelpogs.RegistrationServer_PogsClient{Client: conn.Bootstrap(ctx), Conn: conn}
30-
return &tunnelServerClient{
31-
client: tunnelpogs.TunnelServer_PogsClient{RegistrationServer_PogsClient: registrationClient, Client: conn.Bootstrap(ctx), Conn: conn},
32-
transport: transport,
33-
}
34-
}
35-
36-
func (tsc *tunnelServerClient) Authenticate(ctx context.Context, classicTunnel *ClassicTunnelProperties, registrationOptions *tunnelpogs.RegistrationOptions) (tunnelpogs.AuthOutcome, error) {
37-
authResp, err := tsc.client.Authenticate(ctx, classicTunnel.OriginCert, classicTunnel.Hostname, registrationOptions)
38-
if err != nil {
39-
return nil, err
40-
}
41-
return authResp.Outcome(), nil
42-
}
43-
44-
func (tsc *tunnelServerClient) Close() {
45-
// Closing the client will also close the connection
46-
_ = tsc.client.Close()
47-
_ = tsc.transport.Close()
48-
}
49-
5015
type NamedTunnelRPCClient interface {
5116
RegisterConnection(
5217
c context.Context,

orchestration/orchestrator.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/cloudflare/cloudflared/connection"
1515
"github.com/cloudflare/cloudflared/ingress"
1616
"github.com/cloudflare/cloudflared/proxy"
17-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
17+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
1818
)
1919

2020
// Orchestrator manages configurations, so they can be updatable during runtime
@@ -32,7 +32,7 @@ type Orchestrator struct {
3232
internalRules []ingress.Rule
3333
// cloudflared Configuration
3434
config *Config
35-
tags []tunnelpogs.Tag
35+
tags []pogs.Tag
3636
log *zerolog.Logger
3737

3838
// orchestrator must not handle any more updates after shutdownC is closed
@@ -43,7 +43,7 @@ type Orchestrator struct {
4343

4444
func NewOrchestrator(ctx context.Context,
4545
config *Config,
46-
tags []tunnelpogs.Tag,
46+
tags []pogs.Tag,
4747
internalRules []ingress.Rule,
4848
log *zerolog.Logger) (*Orchestrator, error) {
4949
o := &Orchestrator{
@@ -65,7 +65,7 @@ func NewOrchestrator(ctx context.Context,
6565
}
6666

6767
// UpdateConfig creates a new proxy with the new ingress rules
68-
func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.UpdateConfigurationResponse {
68+
func (o *Orchestrator) UpdateConfig(version int32, config []byte) *pogs.UpdateConfigurationResponse {
6969
o.lock.Lock()
7070
defer o.lock.Unlock()
7171

@@ -74,7 +74,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up
7474
Int32("current_version", o.currentVersion).
7575
Int32("received_version", version).
7676
Msg("Current version is equal or newer than received version")
77-
return &tunnelpogs.UpdateConfigurationResponse{
77+
return &pogs.UpdateConfigurationResponse{
7878
LastAppliedVersion: o.currentVersion,
7979
}
8080
}
@@ -84,7 +84,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up
8484
Int32("version", version).
8585
Str("config", string(config)).
8686
Msgf("Failed to deserialize new configuration")
87-
return &tunnelpogs.UpdateConfigurationResponse{
87+
return &pogs.UpdateConfigurationResponse{
8888
LastAppliedVersion: o.currentVersion,
8989
Err: err,
9090
}
@@ -95,7 +95,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up
9595
Int32("version", version).
9696
Str("config", string(config)).
9797
Msgf("Failed to update ingress")
98-
return &tunnelpogs.UpdateConfigurationResponse{
98+
return &pogs.UpdateConfigurationResponse{
9999
LastAppliedVersion: o.currentVersion,
100100
Err: err,
101101
}
@@ -107,7 +107,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up
107107
Str("config", string(config)).
108108
Msg("Updated to new configuration")
109109
configVersion.Set(float64(version))
110-
return &tunnelpogs.UpdateConfigurationResponse{
110+
return &pogs.UpdateConfigurationResponse{
111111
LastAppliedVersion: o.currentVersion,
112112
}
113113
}

orchestration/orchestrator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import (
2323
"github.com/cloudflare/cloudflared/ingress"
2424
"github.com/cloudflare/cloudflared/management"
2525
"github.com/cloudflare/cloudflared/tracing"
26-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
26+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
2727
)
2828

2929
var (
3030
testLogger = zerolog.Nop()
31-
testTags = []tunnelpogs.Tag{
31+
testTags = []pogs.Tag{
3232
{
3333
Name: "package",
3434
Value: "orchestration",

proxy/proxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/cloudflare/cloudflared/ingress"
2020
"github.com/cloudflare/cloudflared/stream"
2121
"github.com/cloudflare/cloudflared/tracing"
22-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
22+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
2323
)
2424

2525
const (
@@ -33,15 +33,15 @@ type Proxy struct {
3333
ingressRules ingress.Ingress
3434
warpRouting *ingress.WarpRoutingService
3535
management *ingress.ManagementService
36-
tags []tunnelpogs.Tag
36+
tags []pogs.Tag
3737
log *zerolog.Logger
3838
}
3939

4040
// NewOriginProxy returns a new instance of the Proxy struct.
4141
func NewOriginProxy(
4242
ingressRules ingress.Ingress,
4343
warpRouting ingress.WarpRoutingConfig,
44-
tags []tunnelpogs.Tag,
44+
tags []pogs.Tag,
4545
writeTimeout time.Duration,
4646
log *zerolog.Logger,
4747
) *Proxy {

proxy/proxy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import (
3030
"github.com/cloudflare/cloudflared/ingress"
3131
"github.com/cloudflare/cloudflared/logger"
3232
"github.com/cloudflare/cloudflared/tracing"
33-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
33+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
3434
)
3535

3636
var (
37-
testTags = []tunnelpogs.Tag{{Name: "Name", Value: "value"}}
37+
testTags = []pogs.Tag{{Name: "Name", Value: "value"}}
3838
noWarpRouting = ingress.WarpRoutingConfig{}
3939
testWarpRouting = ingress.WarpRoutingConfig{
4040
ConnectTimeout: config.CustomDuration{Duration: time.Second},

supervisor/tunnel.go

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"sync"
1111
"time"
1212

13-
"github.com/google/uuid"
1413
"github.com/pkg/errors"
1514
"github.com/quic-go/quic-go"
1615
"github.com/rs/zerolog"
@@ -27,8 +26,7 @@ import (
2726
quicpogs "github.com/cloudflare/cloudflared/quic"
2827
"github.com/cloudflare/cloudflared/retry"
2928
"github.com/cloudflare/cloudflared/signal"
30-
tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs"
31-
"github.com/cloudflare/cloudflared/tunnelrpc/proto"
29+
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
3230
"github.com/cloudflare/cloudflared/tunnelstate"
3331
)
3432

@@ -49,7 +47,7 @@ type TunnelConfig struct {
4947
HAConnections int
5048
IsAutoupdated bool
5149
LBPool string
52-
Tags []tunnelpogs.Tag
50+
Tags []pogs.Tag
5351
Log *zerolog.Logger
5452
LogTransport *zerolog.Logger
5553
Observer *connection.Observer
@@ -73,34 +71,12 @@ type TunnelConfig struct {
7371
FeatureSelector *features.FeatureSelector
7472
}
7573

76-
func (c *TunnelConfig) registrationOptions(connectionID uint8, OriginLocalIP string, uuid uuid.UUID) *tunnelpogs.RegistrationOptions {
77-
policy := proto.ExistingTunnelPolicy_balance
78-
if c.HAConnections <= 1 && c.LBPool == "" {
79-
policy = proto.ExistingTunnelPolicy_disconnect
80-
}
81-
return &tunnelpogs.RegistrationOptions{
82-
ClientID: c.ClientID,
83-
Version: c.ReportedVersion,
84-
OS: c.OSArch,
85-
ExistingTunnelPolicy: policy,
86-
PoolName: c.LBPool,
87-
Tags: c.Tags,
88-
ConnectionID: connectionID,
89-
OriginLocalIP: OriginLocalIP,
90-
IsAutoupdated: c.IsAutoupdated,
91-
RunFromTerminal: c.RunFromTerminal,
92-
CompressionQuality: 0,
93-
UUID: uuid.String(),
94-
Features: c.SupportedFeatures(),
95-
}
96-
}
97-
98-
func (c *TunnelConfig) connectionOptions(originLocalAddr string, numPreviousAttempts uint8) *tunnelpogs.ConnectionOptions {
74+
func (c *TunnelConfig) connectionOptions(originLocalAddr string, numPreviousAttempts uint8) *pogs.ConnectionOptions {
9975
// attempt to parse out origin IP, but don't fail since it's informational field
10076
host, _, _ := net.SplitHostPort(originLocalAddr)
10177
originIP := net.ParseIP(host)
10278

103-
return &tunnelpogs.ConnectionOptions{
79+
return &pogs.ConnectionOptions{
10480
Client: c.NamedTunnel.Client,
10581
OriginLocalIP: originIP,
10682
ReplaceExisting: c.ReplaceExisting,
@@ -530,7 +506,7 @@ func (e *EdgeTunnelServer) serveHTTP2(
530506
ctx context.Context,
531507
connLog *ConnAwareLogger,
532508
tlsServerConn net.Conn,
533-
connOptions *tunnelpogs.ConnectionOptions,
509+
connOptions *pogs.ConnectionOptions,
534510
controlStreamHandler connection.ControlStreamHandler,
535511
connIndex uint8,
536512
) error {
@@ -572,7 +548,7 @@ func (e *EdgeTunnelServer) serveQUIC(
572548
ctx context.Context,
573549
edgeAddr *net.UDPAddr,
574550
connLogger *ConnAwareLogger,
575-
connOptions *tunnelpogs.ConnectionOptions,
551+
connOptions *pogs.ConnectionOptions,
576552
controlStreamHandler connection.ControlStreamHandler,
577553
connIndex uint8,
578554
) (err error, recoverable bool) {

0 commit comments

Comments
 (0)