zrok/agent/status.go

41 lines
1.1 KiB
Go
Raw Normal View History

package agent
import (
"context"
"github.com/openziti/zrok/agent/agentGrpc"
"sort"
)
2024-09-18 17:54:37 +02:00
func (i *agentGrpcImpl) Status(_ context.Context, _ *agentGrpc.StatusRequest) (*agentGrpc.StatusResponse, error) {
var accesses []*agentGrpc.AccessDetail
2024-09-25 17:06:06 +02:00
for feToken, acc := range i.agent.accesses {
accesses = append(accesses, &agentGrpc.AccessDetail{
FrontendToken: feToken,
Token: acc.token,
BindAddress: acc.bindAddress,
ResponseHeaders: acc.responseHeaders,
})
}
sort.Slice(accesses, func(i, j int) bool {
return accesses[i].FrontendToken < accesses[j].FrontendToken
})
var shares []*agentGrpc.ShareDetail
2024-09-25 17:06:06 +02:00
for token, shr := range i.agent.shares {
shares = append(shares, &agentGrpc.ShareDetail{
Token: token,
ShareMode: string(shr.shareMode),
BackendMode: string(shr.backendMode),
Reserved: shr.reserved,
2024-10-04 21:38:47 +02:00
FrontendEndpoint: shr.frontendEndpoints,
BackendEndpoint: shr.target,
Closed: shr.closed,
})
}
sort.Slice(shares, func(i, j int) bool {
return shares[i].Token < shares[j].Token
})
2024-09-18 17:54:37 +02:00
return &agentGrpc.StatusResponse{Accesses: accesses, Shares: shares}, nil
}