forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremotesite.go
729 lines (642 loc) · 20.9 KB
/
remotesite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/*
Copyright 2015-2019 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package reversetunnel
import (
"context"
"fmt"
"net"
"sync"
"time"
"golang.org/x/crypto/ssh"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/client"
"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/types"
apiutils "github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/api/utils/sshutils"
"github.com/gravitational/teleport/lib/auth"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/srv/forward"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/teleport/lib/utils/interval"
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)
// remoteSite is a remote site that established the inbound connecton to
// the local reverse tunnel server, and now it can provide access to the
// cluster behind it.
type remoteSite struct {
sync.RWMutex
*log.Entry
domainName string
connections []*remoteConn
lastUsed int
srv *server
// connInfo represents the connection to the remote cluster.
connInfo types.TunnelConnection
// lastConnInfo is the last connInfo.
lastConnInfo types.TunnelConnection
ctx context.Context
cancel context.CancelFunc
clock clockwork.Clock
// certificateCache caches host certificates for the forwarding server.
certificateCache *certificateCache
// localClient provides access to the Auth Server API of the cluster
// within which reversetunnel.Server is running.
localClient auth.ClientI
// remoteClient provides access to the Auth Server API of the remote cluster that
// this site belongs to.
remoteClient auth.ClientI
// localAccessPoint provides access to a cached subset of the Auth Server API of
// the local cluster.
localAccessPoint auth.AccessPoint
// remoteAccessPoint provides access to a cached subset of the Auth Server API of
// the remote cluster this site belongs to.
remoteAccessPoint auth.AccessPoint
// remoteCA is the last remote certificate authority recorded by the client.
// It is used to detect CA rotation status changes. If the rotation
// state has been changed, the tunnel will reconnect to re-create the client
// with new settings.
remoteCA types.CertAuthority
// offlineThreshold is how long to wait for a keep alive message before
// marking a reverse tunnel connection as invalid.
offlineThreshold time.Duration
}
func (s *remoteSite) getRemoteClient() (auth.ClientI, bool, error) {
// check if all cert authorities are initiated and if everything is OK
ca, err := s.srv.localAccessPoint.GetCertAuthority(types.CertAuthID{Type: types.HostCA, DomainName: s.domainName}, false)
if err != nil {
return nil, false, trace.Wrap(err)
}
keys := ca.GetTrustedTLSKeyPairs()
// The fact that cluster has keys to remote CA means that the key exchange
// has completed.
if len(keys) != 0 {
s.Debugf("Using TLS client to remote cluster.")
pool, err := services.CertPool(ca)
if err != nil {
return nil, false, trace.Wrap(err)
}
tlsConfig := s.srv.ClientTLS.Clone()
tlsConfig.RootCAs = pool
// encode the name of this cluster to identify this cluster,
// connecting to the remote one (it is used to find the right certificate
// authority to verify)
tlsConfig.ServerName = apiutils.EncodeClusterName(s.srv.ClusterName)
clt, err := auth.NewClient(client.Config{
Dialer: client.ContextDialerFunc(s.authServerContextDialer),
Credentials: []client.Credentials{
client.LoadTLS(tlsConfig),
},
})
if err != nil {
return nil, false, trace.Wrap(err)
}
return clt, false, nil
}
return nil, false, trace.BadParameter("no TLS keys found")
}
func (s *remoteSite) authServerContextDialer(ctx context.Context, network, address string) (net.Conn, error) {
return s.DialAuthServer()
}
// GetTunnelsCount always returns 0 for local cluster
func (s *remoteSite) GetTunnelsCount() int {
return s.connectionCount()
}
func (s *remoteSite) CachingAccessPoint() (auth.AccessPoint, error) {
return s.remoteAccessPoint, nil
}
func (s *remoteSite) GetClient() (auth.ClientI, error) {
return s.remoteClient, nil
}
func (s *remoteSite) String() string {
return fmt.Sprintf("remoteSite(%v)", s.domainName)
}
func (s *remoteSite) connectionCount() int {
s.RLock()
defer s.RUnlock()
return len(s.connections)
}
func (s *remoteSite) hasValidConnections() bool {
s.RLock()
defer s.RUnlock()
for _, conn := range s.connections {
if !conn.isInvalid() {
return true
}
}
return false
}
// Clos closes remote cluster connections
func (s *remoteSite) Close() error {
s.Lock()
defer s.Unlock()
s.cancel()
for i := range s.connections {
s.connections[i].Close()
}
s.connections = []*remoteConn{}
if s.remoteAccessPoint != nil {
return s.remoteAccessPoint.Close()
}
return nil
}
// IsClosed reports whether this remoteSite has been closed.
func (s *remoteSite) IsClosed() bool {
return s.ctx.Err() != nil
}
// nextConn returns next connection that is ready
// and has not been marked as invalid
// it will close connections marked as invalid
func (s *remoteSite) nextConn() (*remoteConn, error) {
s.Lock()
defer s.Unlock()
s.removeInvalidConns()
for i := 0; i < len(s.connections); i++ {
s.lastUsed = (s.lastUsed + 1) % len(s.connections)
remoteConn := s.connections[s.lastUsed]
// connection could have been initated, but agent
// on the other side is not ready yet.
// Proxy assumes that connection is ready to serve when
// it has received a first heartbeat, otherwise
// it could attempt to use it before the agent
// had a chance to start handling connection requests,
// what could lead to proxy marking the connection
// as invalid without a good reason.
if remoteConn.isReady() {
return remoteConn, nil
}
}
return nil, trace.NotFound("%v is offline: no active tunnels to %v found", s.GetName(), s.srv.ClusterName)
}
// removeInvalidConns removes connections marked as invalid,
// it should be called only under write lock
func (s *remoteSite) removeInvalidConns() {
// for first pass, do nothing if no connections are marked
count := 0
for _, conn := range s.connections {
if conn.isInvalid() {
count++
}
}
if count == 0 {
return
}
s.lastUsed = 0
conns := make([]*remoteConn, 0, len(s.connections)-count)
for i := range s.connections {
if !s.connections[i].isInvalid() {
conns = append(conns, s.connections[i])
} else {
go s.connections[i].Close()
}
}
s.connections = conns
}
// addConn helper adds a new active remote cluster connection to the list
// of such connections
func (s *remoteSite) addConn(conn net.Conn, sconn ssh.Conn) (*remoteConn, error) {
s.Lock()
defer s.Unlock()
rconn := newRemoteConn(&connConfig{
conn: conn,
sconn: sconn,
accessPoint: s.localAccessPoint,
tunnelType: string(types.ProxyTunnel),
proxyName: s.connInfo.GetProxyName(),
clusterName: s.domainName,
offlineThreshold: s.offlineThreshold,
})
s.connections = append(s.connections, rconn)
s.lastUsed = 0
return rconn, nil
}
func (s *remoteSite) GetStatus() string {
connInfo, err := s.getLastConnInfo()
if err != nil {
return teleport.RemoteClusterStatusOffline
}
return services.TunnelConnectionStatus(s.clock, connInfo, s.offlineThreshold)
}
func (s *remoteSite) copyConnInfo() types.TunnelConnection {
s.RLock()
defer s.RUnlock()
return s.connInfo.Clone()
}
func (s *remoteSite) setLastConnInfo(connInfo types.TunnelConnection) {
s.Lock()
defer s.Unlock()
s.lastConnInfo = connInfo.Clone()
}
func (s *remoteSite) getLastConnInfo() (types.TunnelConnection, error) {
s.RLock()
defer s.RUnlock()
if s.lastConnInfo == nil {
return nil, trace.NotFound("no last connection found")
}
return s.lastConnInfo.Clone(), nil
}
func (s *remoteSite) registerHeartbeat(t time.Time) {
connInfo := s.copyConnInfo()
connInfo.SetLastHeartbeat(t)
connInfo.SetExpiry(s.clock.Now().Add(s.offlineThreshold))
s.setLastConnInfo(connInfo)
err := s.localAccessPoint.UpsertTunnelConnection(connInfo)
if err != nil {
s.Warningf("Failed to register heartbeat: %v.", err)
}
}
// deleteConnectionRecord deletes connection record to let know peer proxies
// that this node lost the connection and needs to be discovered
func (s *remoteSite) deleteConnectionRecord() {
s.localAccessPoint.DeleteTunnelConnection(s.connInfo.GetClusterName(), s.connInfo.GetName())
}
// fanOutProxies is a non-blocking call that puts the new proxies
// list so that remote connection can notify the remote agent
// about the list update
func (s *remoteSite) fanOutProxies(proxies []types.Server) {
s.Lock()
defer s.Unlock()
for _, conn := range s.connections {
conn.updateProxies(proxies)
}
}
// handleHearbeat receives heartbeat messages from the connected agent
// if the agent has missed several heartbeats in a row, Proxy marks
// the connection as invalid.
func (s *remoteSite) handleHeartbeat(conn *remoteConn, ch ssh.Channel, reqC <-chan *ssh.Request) {
defer func() {
s.Infof("Cluster connection closed.")
conn.Close()
}()
firstHeartbeat := true
for {
select {
case <-s.ctx.Done():
s.Infof("closing")
return
case proxies := <-conn.newProxiesC:
req := discoveryRequest{
ClusterName: s.srv.ClusterName,
Type: conn.tunnelType,
Proxies: proxies,
}
if err := conn.sendDiscoveryRequest(req); err != nil {
s.Debugf("Marking connection invalid on error: %v.", err)
conn.markInvalid(err)
return
}
case req := <-reqC:
if req == nil {
s.Infof("Cluster agent disconnected.")
conn.markInvalid(trace.ConnectionProblem(nil, "agent disconnected"))
if !s.hasValidConnections() {
s.Debugf("Deleting connection record.")
s.deleteConnectionRecord()
}
return
}
if firstHeartbeat {
// as soon as the agent connects and sends a first heartbeat
// send it the list of current proxies back
current := s.srv.proxyWatcher.GetCurrent()
if len(current) > 0 {
conn.updateProxies(current)
}
firstHeartbeat = false
}
var timeSent time.Time
var roundtrip time.Duration
if req.Payload != nil {
if err := timeSent.UnmarshalText(req.Payload); err == nil {
roundtrip = s.srv.Clock.Now().Sub(timeSent)
}
}
if roundtrip != 0 {
s.WithFields(log.Fields{"latency": roundtrip, "nodeID": conn.nodeID}).Debugf("Ping <- %v", conn.conn.RemoteAddr())
} else {
s.WithFields(log.Fields{"nodeID": conn.nodeID}).Debugf("Ping <- %v", conn.conn.RemoteAddr())
}
tm := time.Now().UTC()
conn.setLastHeartbeat(tm)
go s.registerHeartbeat(tm)
// Note that time.After is re-created everytime a request is processed.
case <-time.After(s.offlineThreshold):
conn.markInvalid(trace.ConnectionProblem(nil, "no heartbeats for %v", s.offlineThreshold))
}
}
}
func (s *remoteSite) GetName() string {
return s.domainName
}
func (s *remoteSite) GetLastConnected() time.Time {
connInfo, err := s.getLastConnInfo()
if err != nil {
return time.Time{}
}
return connInfo.GetLastHeartbeat()
}
func (s *remoteSite) compareAndSwapCertAuthority(ca types.CertAuthority) error {
s.Lock()
defer s.Unlock()
if s.remoteCA == nil {
s.remoteCA = ca
return nil
}
rotation := s.remoteCA.GetRotation()
if rotation.Matches(ca.GetRotation()) {
s.remoteCA = ca
return nil
}
s.remoteCA = ca
return trace.CompareFailed("remote certificate authority rotation has been updated")
}
// updateCertAuthorities updates local and remote cert authorities
func (s *remoteSite) updateCertAuthorities() error {
// update main cluster cert authorities on the remote side
// remote side makes sure that only relevant fields
// are updated
hostCA, err := s.localClient.GetCertAuthority(types.CertAuthID{
Type: types.HostCA,
DomainName: s.srv.ClusterName,
}, false)
if err != nil {
return trace.Wrap(err)
}
err = s.remoteClient.RotateExternalCertAuthority(hostCA)
if err != nil {
return trace.Wrap(err)
}
userCA, err := s.localClient.GetCertAuthority(types.CertAuthID{
Type: types.UserCA,
DomainName: s.srv.ClusterName,
}, false)
if err != nil {
return trace.Wrap(err)
}
err = s.remoteClient.RotateExternalCertAuthority(userCA)
if err != nil {
return trace.Wrap(err)
}
// update remote cluster's host cert authoritiy on a local cluster
// local proxy is authorized to perform this operation only for
// host authorities of remote clusters.
remoteCA, err := s.remoteClient.GetCertAuthority(types.CertAuthID{
Type: types.HostCA,
DomainName: s.domainName,
}, false)
if err != nil {
return trace.Wrap(err)
}
if remoteCA.GetClusterName() != s.domainName {
return trace.BadParameter(
"remote cluster sent different cluster name %v instead of expected one %v",
remoteCA.GetClusterName(), s.domainName)
}
oldRemoteCA, err := s.localClient.GetCertAuthority(types.CertAuthID{
Type: types.HostCA,
DomainName: remoteCA.GetClusterName(),
}, false)
if err != nil && !trace.IsNotFound(err) {
return trace.Wrap(err)
}
// if CA is changed or does not exist, update backend
if err != nil || !services.CertAuthoritiesEquivalent(oldRemoteCA, remoteCA) {
if err := s.localClient.UpsertCertAuthority(remoteCA); err != nil {
return trace.Wrap(err)
}
}
// always update our local reference to the cert authority
return s.compareAndSwapCertAuthority(remoteCA)
}
func (s *remoteSite) periodicUpdateCertAuthorities() {
s.Debugf("Updating remote CAs with period %v.", s.srv.PollingPeriod)
periodic := interval.New(interval.Config{
Duration: s.srv.PollingPeriod,
FirstDuration: utils.HalfJitter(s.srv.PollingPeriod),
Jitter: utils.NewSeventhJitter(),
})
defer periodic.Stop()
for {
select {
case <-s.ctx.Done():
s.Debugf("Context is closing.")
return
case <-periodic.Next():
err := s.updateCertAuthorities()
if err != nil {
switch {
case trace.IsNotFound(err):
s.Debugf("Remote cluster %v does not support cert authorities rotation yet.", s.domainName)
case trace.IsCompareFailed(err):
s.Infof("Remote cluster has updated certificate authorities, going to force reconnect.")
s.srv.removeSite(s.domainName)
s.Close()
return
case trace.IsConnectionProblem(err):
s.Debugf("Remote cluster %v is offline.", s.domainName)
default:
s.Warningf("Could not perform cert authorities updated: %v.", trace.DebugReport(err))
}
}
}
}
}
func (s *remoteSite) periodicUpdateLocks() {
s.Debugf("Updating remote locks with period %v.", s.srv.PollingPeriod)
periodic := interval.New(interval.Config{
Duration: s.srv.PollingPeriod,
FirstDuration: utils.HalfJitter(s.srv.PollingPeriod),
Jitter: utils.NewSeventhJitter(),
})
defer periodic.Stop()
for {
select {
case <-s.ctx.Done():
s.Debugf("Context is closing.")
return
case <-periodic.Next():
locks := s.srv.LockWatcher.GetCurrent()
if err := s.remoteClient.ReplaceRemoteLocks(s.ctx, s.srv.ClusterName, locks); err != nil {
switch {
case trace.IsNotImplemented(err):
s.Debugf("Remote cluster %v does not support locks yet.", s.domainName)
case trace.IsConnectionProblem(err):
s.Debugf("Remote cluster %v is offline.", s.domainName)
default:
s.WithError(err).Warning("Could not update remote locks.")
}
}
}
}
}
func (s *remoteSite) DialAuthServer() (net.Conn, error) {
return s.connThroughTunnel(&sshutils.DialReq{
Address: constants.RemoteAuthServer,
})
}
// Dial is used to connect a requesting client (say, tsh) to an SSH server
// located in a remote connected site, the connection goes through the
// reverse proxy tunnel.
func (s *remoteSite) Dial(params DialParams) (net.Conn, error) {
recConfig, err := s.localAccessPoint.GetSessionRecordingConfig(s.ctx)
if err != nil {
return nil, trace.Wrap(err)
}
// If the proxy is in recording mode and a SSH connection is being requested,
// use the agent to dial and build an in-memory forwarding server.
if params.ConnType == types.NodeTunnel && services.IsRecordAtProxy(recConfig.GetMode()) {
return s.dialWithAgent(params)
}
// Attempt to perform a direct TCP dial.
return s.DialTCP(params)
}
func (s *remoteSite) DialTCP(params DialParams) (net.Conn, error) {
s.Debugf("Dialing from %v to %v.", params.From, params.To)
conn, err := s.connThroughTunnel(&sshutils.DialReq{
Address: params.To.String(),
ServerID: params.ServerID,
ConnType: params.ConnType,
})
if err != nil {
return nil, trace.Wrap(err)
}
return conn, nil
}
func (s *remoteSite) dialWithAgent(params DialParams) (net.Conn, error) {
if params.GetUserAgent == nil {
return nil, trace.BadParameter("user agent getter missing")
}
s.Debugf("Dialing with an agent from %v to %v.", params.From, params.To)
// request user agent connection
userAgent, err := params.GetUserAgent()
if err != nil {
return nil, trace.Wrap(err)
}
// Get a host certificate for the forwarding node from the cache.
hostCertificate, err := s.certificateCache.getHostCertificate(params.Address, params.Principals)
if err != nil {
userAgent.Close()
return nil, trace.Wrap(err)
}
targetConn, err := s.connThroughTunnel(&sshutils.DialReq{
Address: params.To.String(),
ServerID: params.ServerID,
ConnType: params.ConnType,
})
if err != nil {
userAgent.Close()
return nil, trace.Wrap(err)
}
// Create a forwarding server that serves a single SSH connection on it. This
// server does not need to close, it will close and release all resources
// once conn is closed.
//
// Note: A localClient is passed to the forwarding server to make sure the
// session gets recorded in the local cluster instead of the remote cluster.
serverConfig := forward.ServerConfig{
AuthClient: s.localClient,
UserAgent: userAgent,
TargetConn: targetConn,
SrcAddr: params.From,
DstAddr: params.To,
HostCertificate: hostCertificate,
Ciphers: s.srv.Config.Ciphers,
KEXAlgorithms: s.srv.Config.KEXAlgorithms,
MACAlgorithms: s.srv.Config.MACAlgorithms,
DataDir: s.srv.Config.DataDir,
Address: params.Address,
UseTunnel: UseTunnel(targetConn),
FIPS: s.srv.FIPS,
HostUUID: s.srv.ID,
Emitter: s.srv.Config.Emitter,
ParentContext: s.srv.Context,
LockWatcher: s.srv.LockWatcher,
}
remoteServer, err := forward.New(serverConfig)
if err != nil {
return nil, trace.Wrap(err)
}
go remoteServer.Serve()
// Return a connection to the forwarding server.
conn, err := remoteServer.Dial()
if err != nil {
return nil, trace.Wrap(err)
}
return conn, nil
}
// UseTunnel makes a channel request asking for the type of connection. If
// the other side does not respond (older cluster) or takes to long to
// respond, be on the safe side and assume it's not a tunnel connection.
func UseTunnel(c *sshutils.ChConn) bool {
responseCh := make(chan bool, 1)
go func() {
ok, err := c.SendRequest(sshutils.ConnectionTypeRequest, true, nil)
if err != nil {
responseCh <- false
return
}
responseCh <- ok
}()
select {
case response := <-responseCh:
return response
case <-time.After(1 * time.Second):
// TODO: remove logrus import
logrus.Debugf("Timed out waiting for response: returning false.")
return false
}
}
func (s *remoteSite) connThroughTunnel(req *sshutils.DialReq) (*sshutils.ChConn, error) {
s.Debugf("Requesting connection to %v [%v] in remote cluster.",
req.Address, req.ServerID)
// Loop through existing remote connections and try and establish a
// connection over the "reverse tunnel".
var conn *sshutils.ChConn
var err error
for i := 0; i < s.connectionCount(); i++ {
conn, err = s.chanTransportConn(req)
if err == nil {
return conn, nil
}
s.Warnf("Request for connection to remote site failed: %v.", err)
}
// Didn't connect and no error? This means we didn't have any connected
// tunnels to try.
if err == nil {
// Return the appropriate message if the user is trying to connect to a
// cluster or a node.
message := fmt.Sprintf("cluster %v is offline", s.GetName())
if req.Address != constants.RemoteAuthServer {
message = fmt.Sprintf("node %v is offline", req.Address)
}
err = trace.ConnectionProblem(nil, message)
}
return nil, err
}
func (s *remoteSite) chanTransportConn(req *sshutils.DialReq) (*sshutils.ChConn, error) {
rconn, err := s.nextConn()
if err != nil {
return nil, trace.Wrap(err)
}
conn, markInvalid, err := sshutils.ConnectProxyTransport(rconn.sconn, req, false)
if err != nil {
if markInvalid {
rconn.markInvalid(err)
}
return nil, trace.Wrap(err)
}
return conn, nil
}