Example #1
0
func (ci *ConnInfo) serveReq(conn ssh.Conn, req *ssh.Request) (err error) {
	r, b, err := conn.SendRequest(req.Type, req.WantReply, req.Payload)
	if err != nil {
		log.Error("%s", err.Error())
		req.Reply(false, nil)
		return err
	}
	log.Debug("send req ok: %s(result: %t)(payload: %d)", req.Type, r, len(b))

	err = req.Reply(r, b)
	if err != nil {
		return err
	}
	log.Debug("reply req ok: %s(result: %t)", req.Type, r)
	return
}
Example #2
0
func (chi *ChanInfo) serveReq(ch ssh.Channel, req *ssh.Request) (err error) {
	err = chi.onReq(req)
	if err != nil {
		log.Error("%s", err.Error())
		req.Reply(false, nil)
		return
	}

	r, err := ch.SendRequest(req.Type, req.WantReply, req.Payload)
	if err != nil {
		log.Error("%s", err.Error())
		req.Reply(false, nil)
		return
	}
	log.Debug("send chan req ok: %s(result: %t)", req.Type, r)

	err = req.Reply(r, nil)
	if err != nil {
		return
	}
	log.Debug("reply chan req ok: %s(result: %t)", req.Type, r)
	return
}