mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-12 17:59:06 +02:00
Fix status and list profiles
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/netbirdio/netbird/client/proto"
|
||||
nbstatus "github.com/netbirdio/netbird/client/status"
|
||||
"github.com/netbirdio/netbird/util"
|
||||
"github.com/netbirdio/netbird/version"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -98,6 +99,14 @@ func statusFunc(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if resp.GetFullStatus() == nil {
|
||||
cmd.Printf("Daemon status: %s\n"+
|
||||
"Daemon version: %s\nCLI version: %s\n\n"+
|
||||
"Detailed status is unavailable: the connection belongs to another user.\n",
|
||||
status, resp.GetDaemonVersion(), version.NetbirdVersion())
|
||||
return nil
|
||||
}
|
||||
|
||||
if ipv4Flag {
|
||||
cmd.Print(parseInterfaceIP(resp.GetFullStatus().GetLocalPeerState().GetIP()))
|
||||
return nil
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/netbirdio/netbird/client/proto"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -47,14 +48,17 @@ func (g *AuthzGate) state() DaemonState {
|
||||
// RequireHolderForFullStatus escalates a StatusRequest that asks for peer detail
|
||||
// or for probes to be run.
|
||||
func RequireHolderForFullStatus(r Request) error {
|
||||
statusReq, ok := r.Msg.(interface {
|
||||
GetGetFullPeerStatus() bool
|
||||
GetShouldRunProbes() bool
|
||||
})
|
||||
statusReq, ok := r.Msg.(*proto.StatusRequest)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if !statusReq.GetGetFullPeerStatus() && !statusReq.GetShouldRunProbes() {
|
||||
if r.Level < AuthzLevelSessionHolder {
|
||||
if statusReq.GetFullPeerStatus {
|
||||
statusReq.GetFullPeerStatus = false
|
||||
}
|
||||
if statusReq.ShouldRunProbes {
|
||||
statusReq.ShouldRunProbes = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return RequireLevel(AuthzLevelSessionHolder)(r)
|
||||
|
||||
@@ -48,6 +48,7 @@ var methodPolicies = map[string]MethodPolicy{
|
||||
// Any identified caller.
|
||||
servicePath + "Status": {Level: AuthzLevelIdentified, Rules: []Rule{RequireHolderForFullStatus}},
|
||||
servicePath + "AddProfile": {Level: AuthzLevelIdentified, Audit: true},
|
||||
servicePath + "ListProfiles": {Level: AuthzLevelIdentified},
|
||||
servicePath + "GetActiveProfile": {Level: AuthzLevelIdentified},
|
||||
servicePath + "GetFeatures": {Level: AuthzLevelIdentified},
|
||||
servicePath + "WailsUIReady": {Level: AuthzLevelIdentified},
|
||||
@@ -67,7 +68,6 @@ var methodPolicies = map[string]MethodPolicy{
|
||||
servicePath + "SwitchProfile": {Level: AuthzLevelSessionHolder, TargetsProfile: true, Audit: true},
|
||||
|
||||
// Owner of some profile
|
||||
servicePath + "ListProfiles": {Level: AuthzLevelProfileOwner},
|
||||
servicePath + "GetLogLevel": {Level: AuthzLevelProfileOwner},
|
||||
servicePath + "ListStates": {Level: AuthzLevelProfileOwner},
|
||||
servicePath + "GetInstallerResult": {Level: AuthzLevelProfileOwner},
|
||||
|
||||
Reference in New Issue
Block a user