feat: Add call duration to call detail view
This commit is contained in:
BIN
inspector.exe
BIN
inspector.exe
Binary file not shown.
@@ -52,11 +52,18 @@ func (s *CallFlowStore) AddPacket(p *Packet) *CallFlow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flow, exists := s.flows[p.CallID]
|
flow, exists := s.flows[p.CallID]
|
||||||
|
|
||||||
|
// Determine timestamp to use
|
||||||
|
ts := p.Timestamp
|
||||||
|
if ts.IsZero() {
|
||||||
|
ts = time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
flow = &CallFlow{
|
flow = &CallFlow{
|
||||||
CallID: p.CallID,
|
CallID: p.CallID,
|
||||||
Packets: make([]*Packet, 0),
|
Packets: make([]*Packet, 0),
|
||||||
StartTime: time.Now(),
|
StartTime: ts,
|
||||||
From: p.From,
|
From: p.From,
|
||||||
To: p.To,
|
To: p.To,
|
||||||
State: CallStateInitial,
|
State: CallStateInitial,
|
||||||
@@ -65,7 +72,10 @@ func (s *CallFlowStore) AddPacket(p *Packet) *CallFlow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flow.Packets = append(flow.Packets, p)
|
flow.Packets = append(flow.Packets, p)
|
||||||
flow.EndTime = time.Now()
|
// Always update EndTime to the latest packet's timestamp
|
||||||
|
if ts.After(flow.EndTime) {
|
||||||
|
flow.EndTime = ts
|
||||||
|
}
|
||||||
|
|
||||||
// Update call state based on packet
|
// Update call state based on packet
|
||||||
s.updateState(flow, p)
|
s.updateState(flow, p)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"telephony-inspector/internal/capture"
|
"telephony-inspector/internal/capture"
|
||||||
"telephony-inspector/internal/config"
|
"telephony-inspector/internal/config"
|
||||||
@@ -713,6 +714,11 @@ func (m Model) renderCallDetail() string {
|
|||||||
b.WriteString(fmt.Sprintf("From: %s\n", flow.From))
|
b.WriteString(fmt.Sprintf("From: %s\n", flow.From))
|
||||||
b.WriteString(fmt.Sprintf("To: %s\n", flow.To))
|
b.WriteString(fmt.Sprintf("To: %s\n", flow.To))
|
||||||
b.WriteString(fmt.Sprintf("State: %s\n", flow.State))
|
b.WriteString(fmt.Sprintf("State: %s\n", flow.State))
|
||||||
|
|
||||||
|
// Calculate and display duration
|
||||||
|
duration := flow.EndTime.Sub(flow.StartTime)
|
||||||
|
b.WriteString(fmt.Sprintf("Duration: %s\n", duration.Round(time.Millisecond)))
|
||||||
|
|
||||||
b.WriteString(fmt.Sprintf("Packets: %d\n\n", len(flow.Packets)))
|
b.WriteString(fmt.Sprintf("Packets: %d\n\n", len(flow.Packets)))
|
||||||
|
|
||||||
// Network Summary Section
|
// Network Summary Section
|
||||||
|
|||||||
Reference in New Issue
Block a user