Skip to content

Commit

Permalink
👍 Fix SIGSEGV bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Takumasa Sakao committed Feb 17, 2018
1 parent 0e89161 commit 564eec5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ TODO
---

* Optimize packets list view.
* Fix SIGSEGV bug.
* Improve detail view, and dump view.
2 changes: 1 addition & 1 deletion panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func preparePacketList() *tview.Table {
SetBackgroundColor(tcell.ColorDefault).
SetBorder(true)

columns := []string{"No.", "Time", "Flow", "Length", "Network Type", "Transport Type"}
columns := []string{"No.", "Time", "Flow", "Length", "Network", "Transport"}
for i, column := range columns {
table.SetCell(0, i,
tview.NewTableCell(column).
Expand Down
23 changes: 18 additions & 5 deletions tcpterm.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,21 @@ func (app *Tcpterm) PacketListGenerator(refreshTrigger chan bool) {
cnt++
rowCount := app.table.GetRowCount()

flow := packet.NetworkLayer().NetworkFlow()
app.logger.Printf("count: %v\n", cnt)
app.logger.Printf("count: %v start\n", cnt)

app.table.SetCell(rowCount, 0, tview.NewTableCell(strconv.Itoa(cnt)))
app.table.SetCell(rowCount, 1, tview.NewTableCell(packet.Metadata().Timestamp.Format(timestampFormt)))
app.table.SetCell(rowCount, 2, tview.NewTableCell(flow.String()))
app.table.SetCell(rowCount, 2, tview.NewTableCell(flowOf(packet)))
app.table.SetCell(rowCount, 3, tview.NewTableCell(strconv.Itoa(packet.Metadata().Length)))
app.table.SetCell(rowCount, 4, tview.NewTableCell(packet.NetworkLayer().LayerType().String()))
app.table.SetCell(rowCount, 5, tview.NewTableCell(packet.TransportLayer().LayerType().String()))
app.table.SetCell(rowCount, 4, tview.NewTableCell(packet.Layers()[1].LayerType().String()))
if len(packet.Layers()) > 2 {
app.table.SetCell(rowCount, 5, tview.NewTableCell(packet.Layers()[2].LayerType().String()))
}

app.packets = append(app.packets, packet)

app.logger.Printf("count: %v end\n", cnt)

if cnt%1000 == 0 {
refreshTrigger <- true
}
Expand Down Expand Up @@ -167,6 +171,7 @@ func (app *Tcpterm) SwitchToTailMode() {
app.table.ScrollToEnd()

app.frame.Clear().AddText("**Tail**", true, tview.AlignLeft, tcell.ColorGreen)

app.frame.AddText("g: page top, G: page end, TAB: rotate panel, Enter: Detail mode", true, tview.AlignRight, tcell.ColorDefault)
}

Expand Down Expand Up @@ -217,3 +222,11 @@ func (app *Tcpterm) findPrimitiveIdx(p tview.Primitive) (int, error) {
}
return 0, errors.New("Primitive not found")
}

func flowOf(packet gopacket.Packet) string {
if packet.NetworkLayer() == nil {
return "-"
} else {
return packet.NetworkLayer().NetworkFlow().String()
}
}

0 comments on commit 564eec5

Please sign in to comment.