mirror of
https://github.com/netbirdio/netbird.git
synced 2025-02-01 19:09:22 +01:00
Make debug ops a bit safer
This commit is contained in:
parent
21a3679590
commit
9b5c0439e9
@ -496,11 +496,20 @@ func (s *Server) SetLogLevel(_ context.Context, req *proto.SetLogLevelRequest) (
|
|||||||
|
|
||||||
log.SetLevel(level)
|
log.SetLevel(level)
|
||||||
|
|
||||||
if s.connectClient != nil &&
|
if s.connectClient == nil {
|
||||||
s.connectClient.Engine() != nil &&
|
return nil, fmt.Errorf("connect client not initialized")
|
||||||
s.connectClient.Engine().GetFirewallManager() != nil {
|
|
||||||
s.connectClient.Engine().GetFirewallManager().SetLogLevel(level)
|
|
||||||
}
|
}
|
||||||
|
engine := s.connectClient.Engine()
|
||||||
|
if engine == nil {
|
||||||
|
return nil, fmt.Errorf("engine not initialized")
|
||||||
|
}
|
||||||
|
|
||||||
|
fwManager := engine.GetFirewallManager()
|
||||||
|
if fwManager == nil {
|
||||||
|
return nil, fmt.Errorf("firewall manager not initialized")
|
||||||
|
}
|
||||||
|
|
||||||
|
fwManager.SetLogLevel(level)
|
||||||
|
|
||||||
log.Infof("Log level set to %s", level.String())
|
log.Infof("Log level set to %s", level.String())
|
||||||
|
|
||||||
|
@ -18,11 +18,15 @@ func (s *Server) TracePacket(_ context.Context, req *proto.TracePacketRequest) (
|
|||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.Unlock()
|
||||||
|
|
||||||
if s.connectClient == nil || s.connectClient.Engine() == nil {
|
if s.connectClient == nil {
|
||||||
|
return nil, fmt.Errorf("connect client not initialized")
|
||||||
|
}
|
||||||
|
engine := s.connectClient.Engine()
|
||||||
|
if engine == nil {
|
||||||
return nil, fmt.Errorf("engine not initialized")
|
return nil, fmt.Errorf("engine not initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
fwManager := s.connectClient.Engine().GetFirewallManager()
|
fwManager := engine.GetFirewallManager()
|
||||||
if fwManager == nil {
|
if fwManager == nil {
|
||||||
return nil, fmt.Errorf("firewall manager not initialized")
|
return nil, fmt.Errorf("firewall manager not initialized")
|
||||||
}
|
}
|
||||||
@ -34,12 +38,12 @@ func (s *Server) TracePacket(_ context.Context, req *proto.TracePacketRequest) (
|
|||||||
|
|
||||||
srcIP := net.ParseIP(req.GetSourceIp())
|
srcIP := net.ParseIP(req.GetSourceIp())
|
||||||
if req.GetSourceIp() == "self" {
|
if req.GetSourceIp() == "self" {
|
||||||
srcIP = s.connectClient.Engine().GetWgAddr()
|
srcIP = engine.GetWgAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
dstIP := net.ParseIP(req.GetDestinationIp())
|
dstIP := net.ParseIP(req.GetDestinationIp())
|
||||||
if req.GetDestinationIp() == "self" {
|
if req.GetDestinationIp() == "self" {
|
||||||
dstIP = s.connectClient.Engine().GetWgAddr()
|
dstIP = engine.GetWgAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
if srcIP == nil || dstIP == nil {
|
if srcIP == nil || dstIP == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user