func newSession(id rsession.ID, r *sessionRegistry, context *ctx) (*session, error) {
	rsess := rsession.Session{
		ID: id,
		TerminalParams: rsession.TerminalParams{
			W: teleport.DefaultTerminalWidth,
			H: teleport.DefaultTerminalHeight,
		},
		Login:      context.login,
		Created:    time.Now().UTC(),
		LastActive: time.Now().UTC(),
		ServerID:   context.srv.ID(),
	}
	term := context.getTerm()
	if term != nil {
		winsize, err := term.getWinsize()
		if err != nil {
			return nil, trace.Wrap(err)
		}
		rsess.TerminalParams.W = int(winsize.Width - 1)
		rsess.TerminalParams.H = int(winsize.Height)
	}
	err := r.srv.sessionServer.CreateSession(rsess)
	if err != nil {
		if trace.IsAlreadyExists(err) {
			// if session already exists, make sure they are compatible
			// Login matches existing login
			existing, err := r.srv.sessionServer.GetSession(id)
			if err != nil {
				return nil, trace.Wrap(err)
			}
			if existing.Login != rsess.Login {
				return nil, trace.AccessDenied(
					"can't switch users from %v to %v for session %v",
					rsess.Login, existing.Login, id)
			}
		}
		// return nil, trace.Wrap(err)
		// No need to abort. Perhaps the auth server is down?
		// Log the error and continue:
		log.Errorf("failed logging new session: %v", err)
	}

	sess := &session{
		id:        id,
		registry:  r,
		parties:   make(map[rsession.ID]*party),
		writer:    newMultiWriter(),
		login:     context.login,
		closeC:    make(chan bool),
		lingerTTL: defaults.SessionRefreshPeriod * 10,
	}
	return sess, nil
}
// newSession creates a new session with a given ID within a given context.
newSession creates a new session with a given ID within a given context.
// newSession creates a new session with a given ID within a given context .
func newSession(id rsession.ID, r *sessionRegistry, context *ctx) (*session, error) {
	rsess := rsession.Session{
		ID: id,
		TerminalParams: rsession.TerminalParams{
			W: teleport.DefaultTerminalWidth,
			H: teleport.DefaultTerminalHeight,
		},
		Login:      context.login,
		Created:    time.Now().UTC(),
		LastActive: time.Now().UTC(),
		ServerID:   context.srv.ID(),
	}
	term := context.getTerm()
	if term != nil {
		winsize, err := term.getWinsize()
		if err != nil {
			return nil, trace.Wrap(err)
		}
		rsess.TerminalParams.W = int(winsize.Width - 1)
		rsess.TerminalParams.H = int(winsize.Height)
	}
	err := r.srv.sessionServer.CreateSession(rsess)
	if err != nil {
		if trace.IsAlreadyExists(err) {
			existing, err := r.srv.sessionServer.GetSession(id)
			if err != nil {
				return nil, trace.Wrap(err)
			}
			if existing.Login != rsess.Login {
				return nil, trace.AccessDenied(
					"can't switch users from %v to %v for session %v",
					rsess.Login, existing.Login, id)
			}
		}
		log.Errorf("failed logging new session: %v", err)
	}
	sess := &session{
		id:        id,
		registry:  r,
		parties:   make(map[rsession.ID]*party),
		writer:    newMultiWriter(),
		login:     context.login,
		closeC:    make(chan bool),
		lingerTTL: defaults.SessionRefreshPeriod * 10,
	}
	return sess, nil
}
func newSession ( id rsession . ID , r * sessionRegistry , context * ctx ) ( * session , error ) { rsess := rsession . Session { ID : id , TerminalParams : rsession . TerminalParams { W : teleport . DefaultTerminalWidth , H : teleport . DefaultTerminalHeight , } , Login : context . login , Created : time . Now ( ) . UTC ( ) , LastActive : time . Now ( ) . UTC ( ) , ServerID : context . srv . ID ( ) , } term := context . getTerm ( ) if term != nil { winsize , err := term . getWinsize ( ) if err != nil { return nil , trace . Wrap ( err ) } rsess . TerminalParams . W = int ( winsize . Width - 1 ) rsess . TerminalParams . H = int ( winsize . Height ) } err := r . srv . sessionServer . CreateSession ( rsess ) if err != nil { if trace . IsAlreadyExists ( err ) { existing , err := r . srv . sessionServer . GetSession ( id ) if err != nil { return nil , trace . Wrap ( err ) } if existing . Login != rsess . Login { return nil , trace . AccessDenied ( " " , rsess . Login , existing . Login , id ) } } log . Errorf ( " " , err ) } sess := & session { id : id , registry : r , parties : make ( map [ rsession . ID ] * party ) , writer : newMultiWriter ( ) , login : context . login , closeC : make ( chan bool ) , lingerTTL : defaults . SessionRefreshPeriod * 10 , } return sess , nil }
newSession creates a new session with a given ID within a given context.
newSession creates a new session with a given ID within a given context .
// if session already exists, make sure they are compatible // Login matches existing login // return nil, trace.Wrap(err) // No need to abort. Perhaps the auth server is down? // Log the error and continue: