Documentation
¶
Index ¶
- func FormatSessionID(callID string) string
- func FormatUserAgent(ua string) string
- func ParseQuery(input string) (string, error)
- type Alias
- type CallRecord
- type CallSummary
- type Client
- func (c *Client) Authenticate(username, password string) error
- func (c *Client) ExportPCAP(params SearchParams) ([]byte, error)
- func (c *Client) FetchCalls(params SearchParams, number string, maxCalls int) ([]CallSummary, error)
- func (c *Client) ListAliases() ([]Alias, error)
- func (c *Client) SearchCalls(params SearchParams) (*SearchResult, error)
- func (c *Client) TestConnection() error
- type SearchParams
- type SearchRecord
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatSessionID ¶ added in v0.34.0
FormatSessionID formats a SIP Call-ID into a compact session identifier. e.g. "824e9152-ab4f-453a-9293-45827b4c96d1" → "824e..96d1" e.g. "1a675a3e795a2f23@172.31.1.2:5060" → "1a67..2f23@172.31.1.2:5060"
func FormatUserAgent ¶ added in v0.34.0
FormatUserAgent transforms raw SIP User-Agent strings into compact display forms. "Asterisk PBX 11.13.1~dfsg-2+deb8u4" → "* 11.13.1" "FPBX-15.0.16.75(16.13.0)" → "FPBX 16.13.0"
func ParseQuery ¶ added in v0.34.0
ParseQuery parses a user query string and returns the Homer smart input equivalent. Field names are validated and mapped to Homer's internal column names. Returns an error for unknown fields or invalid syntax.
Types ¶
type Alias ¶
type Alias struct {
ID float64 `json:"id"`
IP string `json:"ip"`
Port float64 `json:"port"`
Mask float64 `json:"mask"`
Alias string `json:"alias"`
Status bool `json:"status"`
CaptureID string `json:"captureID"`
}
Alias represents a Homer IP/port alias
type CallRecord ¶
type CallRecord struct {
ID float64 `json:"id"`
Date int64 `json:"create_date"`
MicroTS int64 `json:"micro_ts"`
Protocol float64 `json:"protocol"`
SourceIP string `json:"srcIp"`
SourcePort float64 `json:"srcPort"`
DestIP string `json:"dstIp"`
DestPort float64 `json:"dstPort"`
CallID string `json:"sid"`
Method string `json:"method"`
MethodText string `json:"method_text"`
FromUser string `json:"from_user"`
ToUser string `json:"to_user"`
RuriUser string `json:"ruri_user"`
UserAgent string `json:"user_agent"`
CSeq string `json:"cseq"`
Status float64 `json:"status"`
AliasSrc string `json:"aliasSrc"`
AliasDst string `json:"aliasDst"`
Table string `json:"table"`
}
CallRecord represents a raw call record from the Homer API
type CallSummary ¶ added in v0.34.0
type CallSummary struct {
CallID string `json:"call_id"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Duration time.Duration `json:"duration"`
Caller string `json:"caller"`
Callee string `json:"callee"`
Direction string `json:"direction,omitempty"` // "IN", "OUT", or ""
Status string `json:"status"` // "answered", "busy", "cancelled", "no answer", "failed", "ringing"
MsgCount int `json:"msg_count"`
Messages []CallRecord `json:"-"`
}
CallSummary represents a grouped view of a SIP call (all messages sharing one Call-ID)
func GroupCalls ¶ added in v0.34.0
func GroupCalls(records []CallRecord, number string) []CallSummary
GroupCalls groups raw SIP messages by Call-ID and produces call summaries. If number is non-empty, direction is detected relative to that number.
type Client ¶
type Client struct {
Debug bool
// contains filtered or unexported fields
}
Client wraps the Homer 7.x REST API
func (*Client) Authenticate ¶
Authenticate logs in to Homer and stores the JWT token
func (*Client) ExportPCAP ¶
func (c *Client) ExportPCAP(params SearchParams) ([]byte, error)
ExportPCAP exports call messages as a PCAP file
func (*Client) FetchCalls ¶ added in v0.34.0
func (c *Client) FetchCalls(params SearchParams, number string, maxCalls int) ([]CallSummary, error)
FetchCalls discovers calls matching the search parameters. Returns up to maxCalls results.
Uses bounded backward pagination (up to maxBatches × batchLimit messages), walking backwards in time to discover unique Call-IDs. Messages are grouped by Call-ID to produce call summaries.
func (*Client) ListAliases ¶
ListAliases returns all configured IP/port aliases
func (*Client) SearchCalls ¶
func (c *Client) SearchCalls(params SearchParams) (*SearchResult, error)
SearchCalls searches for SIP calls matching the given parameters
func (*Client) TestConnection ¶
TestConnection verifies the Homer API is reachable (unauthenticated health check)
type SearchParams ¶
SearchParams holds search query parameters for Homer API calls
type SearchRecord ¶ added in v0.34.0
type SearchRecord struct {
Date time.Time `json:"date"`
SrcIP string `json:"src_ip"`
SrcPort int `json:"src_port"`
DstIP string `json:"dst_ip"`
DstPort int `json:"dst_port"`
Method string `json:"method"`
FromUser string `json:"from_user"`
ToUser string `json:"to_user"`
CallID string `json:"call_id"`
SessionID string `json:"session_id"`
UserAgent string `json:"user_agent"`
CSeq string `json:"cseq"`
}
SearchRecord is the clean output type for search results. Used by both table and JSON/JSONL output.
func ToSearchRecords ¶ added in v0.34.0
func ToSearchRecords(records []CallRecord) []SearchRecord
ToSearchRecords converts raw API records to clean SearchRecord values.
type SearchResult ¶
type SearchResult struct {
Data []CallRecord `json:"data"`
}
SearchResult holds the response from a call search
func MergeSearchResults ¶ added in v0.34.0
func MergeSearchResults(a, b *SearchResult) *SearchResult
MergeSearchResults deduplicates two search results by message ID.