)
func (s *Sync) hostInfo(conn *rpc.Conn) ([]string, error) {
- x, err := s.loop.SendRecv(s, conn, safcm.MsgInfoReq{
+ resp, err := s.loop.HostInfoMsg(s, conn, safcm.MsgInfoReq{
LogLevel: s.config.LogLevel,
DetectGroups: s.config.DetectGroups,
})
if err != nil {
return nil, err
}
- resp, ok := x.(safcm.MsgInfoResp)
- if !ok {
- return nil, fmt.Errorf("unexpected response %v", x)
- }
if resp.Error != "" {
return nil, fmt.Errorf("%s", resp.Error)
}
package frontend
import (
+ "fmt"
+
"ruderich.org/simon/safcm"
"ruderich.org/simon/safcm/rpc"
)
return x, nil
}
}
+
+// HostInfoMsg sends a MsgInfoReq for host via conn and returns the resulting
+// MsgInfoResp.
+func (l *Loop) HostInfoMsg(host Host, conn *rpc.Conn, req safcm.MsgInfoReq) (
+ safcm.MsgInfoResp, error) {
+
+ var empty safcm.MsgInfoResp
+ x, err := l.SendRecv(host, conn, req)
+ if err != nil {
+ return empty, err
+ }
+ resp, ok := x.(safcm.MsgInfoResp)
+ if !ok {
+ return empty, fmt.Errorf("unexpected response %v", x)
+ }
+ return resp, nil
+}