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