Skip to content

Commit

Permalink
Merge pull request #11 from aojea/logging
Browse files Browse the repository at this point in the history
Fix logging
  • Loading branch information
aojea authored Apr 21, 2024
2 parents 290348d + c6e9059 commit 7daf8bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/networkpolicy/networkpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (c *Controller) acceptNetworkPolicy(p packet) bool {
srcPodNetworkPolices := c.getNetworkPoliciesForPod(srcPod)
dstPodNetworkPolices := c.getNetworkPoliciesForPod(dstPod)

msg := fmt.Sprintf("checking packet %s:", p.String())
msg := fmt.Sprintf("checking packet %s", p.String())
if srcPod != nil {
msg += fmt.Sprintf(" SrcPod (%s/%s): %d NetworkPolicy", srcPod.Name, srcPod.Namespace, len(srcPodNetworkPolices))
msg += fmt.Sprintf("\nSrcPod (%s/%s): %d NetworkPolicy", srcPod.Name, srcPod.Namespace, len(srcPodNetworkPolices))
}
if dstPod != nil {
msg += fmt.Sprintf(" DstPod (%s/%s): %d NetworkPolicy", dstPod.Name, dstPod.Namespace, len(dstPodNetworkPolices))
msg += fmt.Sprintf("\nDstPod (%s/%s): %d NetworkPolicy", dstPod.Name, dstPod.Namespace, len(dstPodNetworkPolices))
}
klog.V(2).Infof("%s", msg)

Expand Down
2 changes: 1 addition & 1 deletion pkg/networkpolicy/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type packet struct {
}

func (p packet) String() string {
return fmt.Sprintf("%s:%d %s:%d %s :: %s", p.srcIP.String(), p.srcPort, p.dstIP.String(), p.dstPort, p.proto, hex.Dump(p.payload))
return fmt.Sprintf("%s:%d %s:%d %s\n%s", p.srcIP.String(), p.srcPort, p.dstIP.String(), p.dstPort, p.proto, hex.Dump(p.payload))
}

// https://en.wikipedia.org/wiki/Internet_Protocol_version_4#Packet_structure
Expand Down

0 comments on commit 7daf8bf

Please sign in to comment.