feat: Resolve IP addresses to node names in packet details view and export
This commit is contained in:
@@ -1378,9 +1378,20 @@ func (m *Model) updateCallDetailView() {
|
||||
var detailsContent string
|
||||
if m.selectedPacketIndex < len(flow.Packets) {
|
||||
pkt := flow.Packets[m.selectedPacketIndex]
|
||||
|
||||
srcLabel := m.networkMap.LabelForIP(pkt.SourceIP)
|
||||
if srcLabel != pkt.SourceIP {
|
||||
srcLabel = fmt.Sprintf("%s (%s)", srcLabel, pkt.SourceIP)
|
||||
}
|
||||
|
||||
dstLabel := m.networkMap.LabelForIP(pkt.DestIP)
|
||||
if dstLabel != pkt.DestIP {
|
||||
dstLabel = fmt.Sprintf("%s (%s)", dstLabel, pkt.DestIP)
|
||||
}
|
||||
|
||||
detailsContent = fmt.Sprintf("Time: %s\nIP: %s -> %s\n\n%s",
|
||||
pkt.Timestamp.Format("15:04:05.000"),
|
||||
pkt.SourceIP, pkt.DestIP,
|
||||
srcLabel, dstLabel,
|
||||
pkt.Raw)
|
||||
} else {
|
||||
detailsContent = "No packet selected"
|
||||
@@ -1544,8 +1555,18 @@ func (m *Model) exportCallToLog(flow *sip.CallFlow, filename string) error {
|
||||
fmt.Fprintf(f, "---------------\n")
|
||||
|
||||
for i, pkt := range flow.Packets {
|
||||
srcLabel := m.networkMap.LabelForIP(pkt.SourceIP)
|
||||
if srcLabel != pkt.SourceIP {
|
||||
srcLabel = fmt.Sprintf("%s (%s)", srcLabel, pkt.SourceIP)
|
||||
}
|
||||
|
||||
dstLabel := m.networkMap.LabelForIP(pkt.DestIP)
|
||||
if dstLabel != pkt.DestIP {
|
||||
dstLabel = fmt.Sprintf("%s (%s)", dstLabel, pkt.DestIP)
|
||||
}
|
||||
|
||||
fmt.Fprintf(f, "\n--- Packet %d [%s] ---\n", i+1, pkt.Timestamp.Format("15:04:05.000"))
|
||||
fmt.Fprintf(f, "%s -> %s\n", pkt.SourceIP, pkt.DestIP)
|
||||
fmt.Fprintf(f, "%s -> %s\n", srcLabel, dstLabel)
|
||||
fmt.Fprintf(f, "%s\n", pkt.Raw)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user