MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / handleChannels

Method handleChannels

internal/sshserver/serverImpl.go:784–821  ·  view source on GitHub ↗
(
	authenticatedMetadata metadata.ConnectionAuthenticatedMetadata,
	channels <-chan ssh.NewChannel,
	connection SSHConnectionHandler,
	logger log.Logger,
)

Source from the content-addressed store, hash-verified

782}
783
784func (s *serverImpl) handleChannels(
785 authenticatedMetadata metadata.ConnectionAuthenticatedMetadata,
786 channels <-chan ssh.NewChannel,
787 connection SSHConnectionHandler,
788 logger log.Logger,
789) {
790 for {
791 newChannel, ok := <-channels
792 if !ok {
793 break
794 }
795 s.lock.Lock()
796 channelID := s.nextChannelID
797 s.nextChannelID++
798 s.lock.Unlock()
799 logger = logger.WithLabel("channelId", channelID)
800 switch newChannel.ChannelType() {
801 case ChannelTypeSession:
802 go s.handleSessionChannel(authenticatedMetadata.Channel(channelID), newChannel, connection, logger)
803 case ChannelTypeDirectTCPIP:
804 go s.handleDirectForwardingChannel(authenticatedMetadata.Channel(channelID), newChannel, connection, logger)
805 case ChannelTypeDirectStreamLocal:
806 go s.handleDirectStreamLocalChannel(authenticatedMetadata.Channel(channelID), newChannel, connection, logger)
807 default:
808 logger.Debug(
809 messageCodes.NewMessage(
810 messageCodes.ESSHUnsupportedChannelType,
811 "Unsupported channel type requested",
812 ).Label("type", newChannel.ChannelType()),
813 )
814 connection.OnUnsupportedChannel(channelID, newChannel.ChannelType(), newChannel.ExtraData())
815 if err := newChannel.Reject(ssh.UnknownChannelType, "unsupported channel type"); err != nil {
816 logger.Debug("failed to send channel rejection for channel type %s", newChannel.ChannelType())
817 }
818 continue
819 }
820 }
821}
822
823func (s *serverImpl) handleSessionChannel(
824 channelMetadata metadata.ChannelMetadata,

Callers 1

handleConnectionMethod · 0.95

Calls 9

handleSessionChannelMethod · 0.95
ChannelMethod · 0.80
RejectMethod · 0.80
WithLabelMethod · 0.65
DebugMethod · 0.65
LabelMethod · 0.65
OnUnsupportedChannelMethod · 0.65

Tested by

no test coverage detected