diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index c07e9bd284..8f588ebdc4 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -656,17 +656,17 @@ func (hv *Hypervisor) deleteRoute() http.HandlerFunc { }) } -type loopResp struct { +type routeGroupResp struct { routing.RuleConsumeFields FwdRule routing.RuleForwardFields `json:"resp"` } -func makeLoopResp(info visor.LoopInfo) loopResp { +func makeRouteGroupResp(info visor.RouteGroupInfo) routeGroupResp { if len(info.FwdRule) == 0 || len(info.ConsumeRule) == 0 { - return loopResp{} + return routeGroupResp{} } - return loopResp{ + return routeGroupResp{ RuleConsumeFields: *info.ConsumeRule.Summary().ConsumeFields, FwdRule: *info.FwdRule.Summary().ForwardFields, } @@ -674,15 +674,15 @@ func makeLoopResp(info visor.LoopInfo) loopResp { func (hv *Hypervisor) getRouteGroup() http.HandlerFunc { return hv.withCtx(hv.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { - loops, err := ctx.RPC.RouteGroups() + rg, err := ctx.RPC.RouteGroups() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) return } - resp := make([]loopResp, len(loops)) - for i, l := range loops { - resp[i] = makeLoopResp(l) + resp := make([]routeGroupResp, len(rg)) + for i, l := range rg { + resp[i] = makeRouteGroupResp(l) } httputil.WriteJSON(w, r, http.StatusOK, resp) diff --git a/pkg/visor/rpc.go b/pkg/visor/rpc.go index 92f725ef4c..7ad0f47dd8 100644 --- a/pkg/visor/rpc.go +++ b/pkg/visor/rpc.go @@ -450,21 +450,21 @@ func (r *RPC) RemoveRoutingRule(key *routing.RouteID, _ *struct{}) (err error) { } /* - <<< LOOPS MANAGEMENT >>> + <<< ROUTEGROUPS MANAGEMENT >>> >>> TODO(evanlinjin): Implement. */ -// LoopInfo is a human-understandable representation of a loop. -type LoopInfo struct { +// RouteGroupInfo is a human-understandable representation of a RouteGroup. +type RouteGroupInfo struct { ConsumeRule routing.Rule FwdRule routing.Rule } -// RouteGroups retrieves loops via rules of the routing table. -func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) (err error) { +// RouteGroups retrieves routegroups via rules of the routing table. +func (r *RPC) RouteGroups(_ *struct{}, out *[]RouteGroupInfo) (err error) { defer r.logReq("RouteGroups", nil)(out, &err) - var loops []LoopInfo + var routegroups []RouteGroupInfo rules := r.visor.router.Rules() for _, rule := range rules { @@ -478,13 +478,13 @@ func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) (err error) { return err } - loops = append(loops, LoopInfo{ + routegroups = append(routegroups, RouteGroupInfo{ ConsumeRule: rule, FwdRule: rule, }) } - *out = loops + *out = routegroups return nil } diff --git a/pkg/visor/rpc_client.go b/pkg/visor/rpc_client.go index cb46a0afd0..e30eeae4c2 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -57,7 +57,7 @@ type RPCClient interface { SaveRoutingRule(rule routing.Rule) error RemoveRoutingRule(key routing.RouteID) error - RouteGroups() ([]LoopInfo, error) + RouteGroups() ([]RouteGroupInfo, error) Restart() error Exec(command string) ([]byte, error) @@ -231,10 +231,10 @@ func (rc *rpcClient) RemoveRoutingRule(key routing.RouteID) error { } // RouteGroups calls RouteGroups. -func (rc *rpcClient) RouteGroups() ([]LoopInfo, error) { - var loops []LoopInfo - err := rc.Call("RouteGroups", &struct{}{}, &loops) - return loops, err +func (rc *rpcClient) RouteGroups() ([]RouteGroupInfo, error) { + var routegroups []RouteGroupInfo + err := rc.Call("RouteGroups", &struct{}{}, &routegroups) + return routegroups, err } // Restart calls Restart. @@ -581,8 +581,8 @@ func (mc *mockRPCClient) RemoveRoutingRule(key routing.RouteID) error { } // RouteGroups implements RPCClient. -func (mc *mockRPCClient) RouteGroups() ([]LoopInfo, error) { - var loops []LoopInfo +func (mc *mockRPCClient) RouteGroups() ([]RouteGroupInfo, error) { + var loops []RouteGroupInfo rules := mc.rt.AllRules() for _, rule := range rules { @@ -595,7 +595,7 @@ func (mc *mockRPCClient) RouteGroups() ([]LoopInfo, error) { if err != nil { return nil, err } - loops = append(loops, LoopInfo{ + loops = append(loops, RouteGroupInfo{ ConsumeRule: rule, FwdRule: fwdRule, }) diff --git a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go index b3237d959d..6555c17910 100644 --- a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go +++ b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go @@ -152,7 +152,7 @@ type Server struct { // Port in which the DMSG Server is listening for connections. Port string `json:"port"` - // Number of connections still available. + // Number of connections still available.180 AvailableConnections int `json:"available_connections"` } diff --git a/vendor/github.com/SkycoinProject/dmsg/httputil/error.go b/vendor/github.com/SkycoinProject/dmsg/httputil/error.go index 5b545990a2..0752c6a05e 100644 --- a/vendor/github.com/SkycoinProject/dmsg/httputil/error.go +++ b/vendor/github.com/SkycoinProject/dmsg/httputil/error.go @@ -1,6 +1,7 @@ package httputil import ( + "bytes" "fmt" "io/ioutil" "net/http" @@ -22,7 +23,7 @@ func ErrorFromResp(resp *http.Response) error { if err != nil && len(msg) == 0 { msg = []byte(fmt.Sprintf("failed to read HTTP response body: %v", err)) } - return &HTTPError{Status: status, Body: string(msg)} + return &HTTPError{Status: status, Body: string(bytes.TrimSpace(msg))} } // Error returns the error message. diff --git a/vendor/modules.txt b/vendor/modules.txt index 2ece7f09d8..22ec8c199d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb +# github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb => ../dmsg github.com/SkycoinProject/dmsg github.com/SkycoinProject/dmsg/cipher github.com/SkycoinProject/dmsg/disc