Pārlūkot izejas kodu

drop packets even if we aren't going to emit Debug logs about it (#239)

* drop packets even if we aren't going to emit Debug logs about it

* smallify change
Patrick Bogen 5 gadi atpakaļ
vecāks
revīzija
ecf0e5a9f6
2 mainītis faili ar 12 papildinājumiem un 8 dzēšanām
  1. 6 4
      inside.go
  2. 6 4
      outside.go

+ 6 - 4
inside.go

@@ -109,10 +109,12 @@ func (f *Interface) sendMessageNow(t NebulaMessageType, st NebulaMessageSubType,
 
 
 	// check if packet is in outbound fw rules
 	// check if packet is in outbound fw rules
 	dropReason := f.firewall.Drop(p, *fp, false, hostInfo, trustedCAs)
 	dropReason := f.firewall.Drop(p, *fp, false, hostInfo, trustedCAs)
-	if dropReason != nil && l.Level >= logrus.DebugLevel {
-		l.WithField("fwPacket", fp).
-			WithField("reason", dropReason).
-			Debugln("dropping cached packet")
+	if dropReason != nil {
+		if l.Level >= logrus.DebugLevel {
+			l.WithField("fwPacket", fp).
+				WithField("reason", dropReason).
+				Debugln("dropping cached packet")
+		}
 		return
 		return
 	}
 	}
 
 

+ 6 - 4
outside.go

@@ -281,10 +281,12 @@ func (f *Interface) decryptToTun(hostinfo *HostInfo, messageCounter uint64, out
 	}
 	}
 
 
 	dropReason := f.firewall.Drop(out, *fwPacket, true, hostinfo, trustedCAs)
 	dropReason := f.firewall.Drop(out, *fwPacket, true, hostinfo, trustedCAs)
-	if dropReason != nil && l.Level >= logrus.DebugLevel {
-		hostinfo.logger().WithField("fwPacket", fwPacket).
-			WithField("reason", dropReason).
-			Debugln("dropping inbound packet")
+	if dropReason != nil {
+		if l.Level >= logrus.DebugLevel {
+			hostinfo.logger().WithField("fwPacket", fwPacket).
+				WithField("reason", dropReason).
+				Debugln("dropping inbound packet")
+		}
 		return
 		return
 	}
 	}