func (s *Server) HandleNewChan(nc net.Conn, sconn *ssh.ServerConn, nch ssh.NewChannel) {
	channelType := nch.ChannelType()
	if s.proxyMode {
		if channelType == "session" { // interactive sessions
			ch, requests, err := nch.Accept()
			if err != nil {
				log.Infof("could not accept channel (%s)", err)
			}
			go s.handleSessionRequests(sconn, ch, requests)
		} else {
			nch.Reject(ssh.UnknownChannelType, fmt.Sprintf("unknown channel type: %v", channelType))
		}
		return
	}

	switch channelType {
	// a client requested the terminal size to be sent along with every
	// session message (Teleport-specific SSH channel for web-based terminals)
	case "x-teleport-request-resize-events":
		ch, _, _ := nch.Accept()
		go s.handleTerminalResize(sconn, ch)
	case "session": // interactive sessions
		ch, requests, err := nch.Accept()
		if err != nil {
			log.Infof("could not accept channel (%s)", err)
		}
		go s.handleSessionRequests(sconn, ch, requests)
	case "direct-tcpip": //port forwarding
		req, err := sshutils.ParseDirectTCPIPReq(nch.ExtraData())
		if err != nil {
			log.Errorf("failed to parse request data: %v, err: %v", string(nch.ExtraData()), err)
			nch.Reject(ssh.UnknownChannelType, "failed to parse direct-tcpip request")
		}
		ch, _, err := nch.Accept()
		if err != nil {
			log.Infof("could not accept channel (%s)", err)
		}
		go s.handleDirectTCPIPRequest(sconn, ch, req)
	default:
		nch.Reject(ssh.UnknownChannelType, fmt.Sprintf("unknown channel type: %v", channelType))
	}
}
// HandleNewChan is called when new channel is opened
HandleNewChan is called when new channel is opened
// HandleNewChan is called when new channel is opened
func (s *Server) HandleNewChan(nc net.Conn, sconn *ssh.ServerConn, nch ssh.NewChannel) {
	channelType := nch.ChannelType()
	if s.proxyMode {
		if channelType == "session" { 
			ch, requests, err := nch.Accept()
			if err != nil {
				log.Infof("could not accept channel (%s)", err)
			}
			go s.handleSessionRequests(sconn, ch, requests)
		} else {
			nch.Reject(ssh.UnknownChannelType, fmt.Sprintf("unknown channel type: %v", channelType))
		}
		return
	}
	switch channelType {
	case "x-teleport-request-resize-events":
		ch, _, _ := nch.Accept()
		go s.handleTerminalResize(sconn, ch)
	case "session": 
		ch, requests, err := nch.Accept()
		if err != nil {
			log.Infof("could not accept channel (%s)", err)
		}
		go s.handleSessionRequests(sconn, ch, requests)
	case "direct-tcpip": 
		req, err := sshutils.ParseDirectTCPIPReq(nch.ExtraData())
		if err != nil {
			log.Errorf("failed to parse request data: %v, err: %v", string(nch.ExtraData()), err)
			nch.Reject(ssh.UnknownChannelType, "failed to parse direct-tcpip request")
		}
		ch, _, err := nch.Accept()
		if err != nil {
			log.Infof("could not accept channel (%s)", err)
		}
		go s.handleDirectTCPIPRequest(sconn, ch, req)
	default:
		nch.Reject(ssh.UnknownChannelType, fmt.Sprintf("unknown channel type: %v", channelType))
	}
}
func ( s * Server ) HandleNewChan ( nc net . Conn , sconn * ssh . ServerConn , nch ssh . NewChannel ) { channelType := nch . ChannelType ( ) if s . proxyMode { if channelType == " " { ch , requests , err := nch . Accept ( ) if err != nil { log . Infof ( " " , err ) } go s . handleSessionRequests ( sconn , ch , requests ) } else { nch . Reject ( ssh . UnknownChannelType , fmt . Sprintf ( " " , channelType ) ) } return } switch channelType { case " " : ch , _ , _ := nch . Accept ( ) go s . handleTerminalResize ( sconn , ch ) case " " : ch , requests , err := nch . Accept ( ) if err != nil { log . Infof ( " " , err ) } go s . handleSessionRequests ( sconn , ch , requests ) case " " : req , err := sshutils . ParseDirectTCPIPReq ( nch . ExtraData ( ) ) if err != nil { log . Errorf ( " " , string ( nch . ExtraData ( ) ) , err ) nch . Reject ( ssh . UnknownChannelType , " " ) } ch , _ , err := nch . Accept ( ) if err != nil { log . Infof ( " " , err ) } go s . handleDirectTCPIPRequest ( sconn , ch , req ) default : nch . Reject ( ssh . UnknownChannelType , fmt . Sprintf ( " " , channelType ) ) } }
HandleNewChan is called when new channel is opened
HandleNewChan is called when new channel is opened
// interactive sessions // a client requested the terminal size to be sent along with every // session message (Teleport-specific SSH channel for web-based terminals) // interactive sessions //port forwarding