TUN-2460: Configure according to the ClientConfig recevied from a successful Connect
This commit is contained in:
parent
ad9559c66a
commit
a52f47c9a9
|
@ -10,7 +10,9 @@ import (
|
||||||
|
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/buildinfo"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/buildinfo"
|
||||||
"github.com/cloudflare/cloudflared/h2mux"
|
"github.com/cloudflare/cloudflared/h2mux"
|
||||||
|
"github.com/cloudflare/cloudflared/streamhandler"
|
||||||
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -25,7 +27,7 @@ const (
|
||||||
// EdgeManager manages connections with the edge
|
// EdgeManager manages connections with the edge
|
||||||
type EdgeManager struct {
|
type EdgeManager struct {
|
||||||
// streamHandler handles stream opened by the edge
|
// streamHandler handles stream opened by the edge
|
||||||
streamHandler h2mux.MuxedStreamHandler
|
streamHandler *streamhandler.StreamHandler
|
||||||
// TLSConfig is the TLS configuration to connect with edge
|
// TLSConfig is the TLS configuration to connect with edge
|
||||||
tlsConfig *tls.Config
|
tlsConfig *tls.Config
|
||||||
// cloudflaredConfig is the cloudflared configuration that is determined when the process first starts
|
// cloudflaredConfig is the cloudflared configuration that is determined when the process first starts
|
||||||
|
@ -52,7 +54,7 @@ type CloudflaredConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEdgeManager(
|
func NewEdgeManager(
|
||||||
streamHandler h2mux.MuxedStreamHandler,
|
streamHandler *streamhandler.StreamHandler,
|
||||||
edgeConnMgrConfigurable *EdgeManagerConfigurable,
|
edgeConnMgrConfigurable *EdgeManagerConfigurable,
|
||||||
userCredential []byte,
|
userCredential []byte,
|
||||||
tlsConfig *tls.Config,
|
tlsConfig *tls.Config,
|
||||||
|
@ -155,6 +157,8 @@ func (em *EdgeManager) newConnection(ctx context.Context) *pogs.ConnectError {
|
||||||
|
|
||||||
em.state.newConnection(h2muxConn)
|
em.state.newConnection(h2muxConn)
|
||||||
em.logger.Infof("connected to %s", connResult.ConnectedTo())
|
em.logger.Infof("connected to %s", connResult.ConnectedTo())
|
||||||
|
|
||||||
|
em.streamHandler.UseConfiguration(ctx, connResult.ClientConfig())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,9 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/cloudflare/cloudflared/h2mux"
|
"github.com/cloudflare/cloudflared/h2mux"
|
||||||
|
"github.com/cloudflare/cloudflared/streamhandler"
|
||||||
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -42,16 +44,12 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockStreamHandler struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (msh *mockStreamHandler) ServeStream(*h2mux.MuxedStream) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func mockEdgeManager() *EdgeManager {
|
func mockEdgeManager() *EdgeManager {
|
||||||
|
newConfigChan := make(chan<- *pogs.ClientConfig)
|
||||||
|
useConfigResultChan := make(<-chan *pogs.UseConfigurationResult)
|
||||||
|
logger := logrus.New()
|
||||||
return NewEdgeManager(
|
return NewEdgeManager(
|
||||||
&mockStreamHandler{},
|
streamhandler.NewStreamHandler(newConfigChan, useConfigResultChan, logger),
|
||||||
configurable,
|
configurable,
|
||||||
[]byte{},
|
[]byte{},
|
||||||
nil,
|
nil,
|
||||||
|
|
Loading…
Reference in New Issue