MCPcopy Index your code
hub / github.com/devspace-sh/devspace / handler

Method handler

pkg/devspace/services/proxycommands/server.go:81–124  ·  view source on GitHub ↗
(sess ssh.Session)

Source from the content-addressed store, hash-verified

79}
80
81func (s *Server) handler(sess ssh.Session) {
82 cmd, payload, err := s.getCommand(sess)
83 if err != nil {
84 s.exitWithError(sess, errors.Wrap(err, "construct command"))
85 return
86 }
87
88 if ssh.AgentRequested(sess) {
89 l, err := ssh.NewAgentListener()
90 if err != nil {
91 s.exitWithError(sess, errors.Wrap(err, "start agent"))
92 return
93 }
94
95 defer l.Close()
96 go ssh.ForwardAgentConnections(l, sess)
97 cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", "SSH_AUTH_SOCK", l.Addr().String()))
98 }
99
100 // start shell session
101 if payload.TTY && runtime.GOOS != "windows" {
102 winSizeChan := make(chan ssh.Window, 1)
103 winSizeChan <- ssh.Window{
104 Width: payload.Width,
105 Height: payload.Height,
106 }
107 err = sshhelper.HandlePTY(sess, ssh.Pty{
108 Term: "xterm",
109 Window: ssh.Window{
110 Width: payload.Width,
111 Height: payload.Height,
112 },
113 }, winSizeChan, cmd, func(reader io.Reader) io.Reader {
114 return reader
115 })
116 } else {
117 err = sshhelper.HandleNonPTY(sess, cmd, func(reader io.Reader) io.Reader {
118 return NewRewriter(reader, s.rewriteMappings)
119 })
120 }
121
122 // exit session
123 s.exitWithError(sess, err)
124}
125
126func (s *Server) getCommand(sess ssh.Session) (*exec.Cmd, *types.ProxyCommand, error) {
127 var cmd *exec.Cmd

Callers

nothing calls this directly

Calls 6

getCommandMethod · 0.95
exitWithErrorMethod · 0.95
NewRewriterFunction · 0.85
AddrMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected