| 320 | } |
| 321 | |
| 322 | func (srv *Server) handleRequests(ctx Context, in <-chan *gossh.Request) { |
| 323 | for req := range in { |
| 324 | handler := srv.RequestHandlers[req.Type] |
| 325 | if handler == nil { |
| 326 | handler = srv.RequestHandlers["default"] |
| 327 | } |
| 328 | if handler == nil { |
| 329 | req.Reply(false, nil) |
| 330 | continue |
| 331 | } |
| 332 | /*reqCtx, cancel := context.WithCancel(ctx) |
| 333 | defer cancel() */ |
| 334 | ret, payload := handler(ctx, srv, req) |
| 335 | req.Reply(ret, payload) |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | // ListenAndServe listens on the TCP network address srv.Addr and then calls |
| 340 | // Serve to handle incoming connections. If srv.Addr is blank, ":22" is used. |