func (s *tunnelSite) dialAccessPoint(network, addr string) (net.Conn, error) {
	s.log.Infof("[TUNNEL] dial to site '%s'", s.GetName())

	try := func() (net.Conn, error) {
		remoteConn, err := s.nextConn()
		if err != nil {
			return nil, trace.Wrap(err)
		}
		ch, _, err := remoteConn.sshConn.OpenChannel(chanAccessPoint, nil)
		if err != nil {
			remoteConn.markInvalid(err)
			s.log.Errorf("[TUNNEL] disconnecting site '%s' on %v. Err: %v",
				s.GetName(),
				remoteConn.conn.RemoteAddr(),
				err)
			return nil, trace.Wrap(err)
		}
		s.log.Infof("[TUNNEL] success dialing to site '%s'", s.GetName())
		return utils.NewChConn(remoteConn.sshConn, ch), nil
	}

	for {
		conn, err := try()
		if err != nil {
			if trace.IsNotFound(err) {
				return nil, trace.Wrap(err)
			}
			continue
		}
		return conn, nil
	}
}
// dialAccessPoint establishes a connection from the proxy (reverse tunnel server)
// back into the client using previously established tunnel.
dialAccessPoint establishes a connection from the proxy (reverse tunnel server)
back into the client using previously established tunnel.
// dialAccessPoint establishes a connection from the proxy ( reverse tunnel server ) // back into the client using previously established tunnel .
func (s *tunnelSite) dialAccessPoint(network, addr string) (net.Conn, error) {
	s.log.Infof("[TUNNEL] dial to site '%s'", s.GetName())
	try := func() (net.Conn, error) {
		remoteConn, err := s.nextConn()
		if err != nil {
			return nil, trace.Wrap(err)
		}
		ch, _, err := remoteConn.sshConn.OpenChannel(chanAccessPoint, nil)
		if err != nil {
			remoteConn.markInvalid(err)
			s.log.Errorf("[TUNNEL] disconnecting site '%s' on %v. Err: %v",
				s.GetName(),
				remoteConn.conn.RemoteAddr(),
				err)
			return nil, trace.Wrap(err)
		}
		s.log.Infof("[TUNNEL] success dialing to site '%s'", s.GetName())
		return utils.NewChConn(remoteConn.sshConn, ch), nil
	}
	for {
		conn, err := try()
		if err != nil {
			if trace.IsNotFound(err) {
				return nil, trace.Wrap(err)
			}
			continue
		}
		return conn, nil
	}
}
func ( s * tunnelSite ) dialAccessPoint ( network , addr string ) ( net . Conn , error ) { s . log . Infof ( " " , s . GetName ( ) ) try := func ( ) ( net . Conn , error ) { remoteConn , err := s . nextConn ( ) if err != nil { return nil , trace . Wrap ( err ) } ch , _ , err := remoteConn . sshConn . OpenChannel ( chanAccessPoint , nil ) if err != nil { remoteConn . markInvalid ( err ) s . log . Errorf ( " " , s . GetName ( ) , remoteConn . conn . RemoteAddr ( ) , err ) return nil , trace . Wrap ( err ) } s . log . Infof ( " " , s . GetName ( ) ) return utils . NewChConn ( remoteConn . sshConn , ch ) , nil } for { conn , err := try ( ) if err != nil { if trace . IsNotFound ( err ) { return nil , trace . Wrap ( err ) } continue } return conn , nil } }
dialAccessPoint establishes a connection from the proxy (reverse tunnel server)
back into the client using previously established tunnel.
dialAccessPoint establishes a connection from the proxy ( reverse tunnel server ) back into the client using previously established tunnel .