diff --git a/viewer/sidebar.go b/viewer/sidebar.go index 90de634..de2e7b0 100644 --- a/viewer/sidebar.go +++ b/viewer/sidebar.go @@ -49,7 +49,7 @@ func (m *sidebarModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmds []tea.Cmd switch msg := msg.(type) { - case *Item: + case UpdateItem: m.Data = msg content := m.getSidebarContents() @@ -132,19 +132,23 @@ func (m *sidebarModel) getSidebarContents() string { modifierLabel := sectionStyle.Render("「 Threat Modifiers 」") modifiers := m.renderModifiers() - connInfoLabel := sectionStyle.Render("「 Connection Info 」") - dataStyle := lipgloss.NewStyle().Foreground(defaultTextColor) - // get connection count - connCountStyle := lipgloss.NewStyle().Background(overlay2).Foreground(base).Bold(true).Padding(0, 2) - connCountHeader := connCountStyle.Render("Connection Count") - connCount := dataStyle.Render(lipgloss.JoinVertical(lipgloss.Top, connCountHeader, fmt.Sprintf("%d", m.Data.Count))) + var connInfoLabel, connCount, bytes string + // display connection count and bytes for everything except C2 over DNS + if m.Data.C2OverDNSScore == 0 { + connInfoLabel = sectionStyle.Render("「 Connection Info 」") + + // get connection count + connCountStyle := lipgloss.NewStyle().Background(overlay2).Foreground(base).Bold(true).Padding(0, 2) + connCountHeader := connCountStyle.Render("Connection Count") + connCount = dataStyle.Render(lipgloss.JoinVertical(lipgloss.Top, connCountHeader, fmt.Sprintf("%d", m.Data.Count))) - // get total bytes - bytesHeaderStyle := lipgloss.NewStyle().Background(overlay2).Foreground(base).Bold(true).Padding(0, 2) - bytesHeader := bytesHeaderStyle.Render("Total Bytes") - bytes := dataStyle.Render(lipgloss.JoinVertical(lipgloss.Top, bytesHeader, m.Data.TotalBytesFormatted)) + // get total bytes + bytesHeaderStyle := lipgloss.NewStyle().Background(overlay2).Foreground(base).Bold(true).Padding(0, 2) + bytesHeader := bytesHeaderStyle.Render("Total Bytes") + bytes = dataStyle.Render(lipgloss.JoinVertical(lipgloss.Top, bytesHeader, m.Data.TotalBytesFormatted)) + } // get port:proto:service portProtoService := m.Data.GetPortProtoService() @@ -163,11 +167,6 @@ func (m *sidebarModel) getSidebarContents() string { // render header portsHeader := portsHeaderStyle.Render("Port : Proto : Service") ports = dataStyle.Render(lipgloss.JoinVertical(lipgloss.Top, portsHeader, strings.Join(portProtoService, "\n"))) - // strings.Join(portProtoService, "\n") - // calculate the number of lines available for port data - // remainingLines := m.viewport.Height - (lipgloss.Height(heading) + lipgloss.Height(modifiers) + lipgloss.Height(modifierLabel) + lipgloss.Height(connInfoLabel) + lipgloss.Height(bytes) + lipgloss.Height(connCount)) - // ports = renderPorts(portProtoService, m.viewport.Width, remainingLines) - } // join contents diff --git a/viewer/viewer.go b/viewer/viewer.go index ae1fb28..4b98b10 100644 --- a/viewer/viewer.go +++ b/viewer/viewer.go @@ -277,13 +277,13 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // set sidebar data to the selected item if data, ok := m.List.Rows.Items()[m.List.Rows.Index()].(*Item); ok { - _, cmd := m.SideBar.Update(data) + _, cmd := m.SideBar.Update(UpdateItem(data)) cmds = append(cmds, cmd) } } else { // if there are no items to display, set the sidebar data to nil - _, cmd := m.SideBar.Update(nil) + _, cmd := m.SideBar.Update(UpdateItem(nil)) cmds = append(cmds, cmd) }