This commit is contained in:
Neale Pickett 2020-06-30 18:28:21 -06:00
parent ac599bb481
commit dd6e4859f4
1 changed files with 8 additions and 9 deletions

View File

@ -2,13 +2,13 @@ package main
import ( import (
"fmt" "fmt"
"github.com/dirtbags/netshovel"
"github.com/google/gopacket"
"github.com/google/gopacket/tcpassembly"
"io" "io"
"log" "log"
"strings" "strings"
"sync" "sync"
"github.com/google/gopacket"
"github.com/google/gopacket/tcpassembly"
"github.com/dirtbags/netshovel"
) )
var wg sync.WaitGroup var wg sync.WaitGroup
@ -45,16 +45,15 @@ func (stream SimpleStream) Display(pkt SimplePacket) {
fmt.Fprintf(out, "Simple %v:%v → %v:%v\n", fmt.Fprintf(out, "Simple %v:%v → %v:%v\n",
stream.Net.Src().String(), stream.Transport.Src().String(), stream.Net.Src().String(), stream.Transport.Src().String(),
stream.Net.Dst().String(), stream.Transport.Dst().String(), stream.Net.Dst().String(), stream.Transport.Dst().String(),
) )
out.WriteString(pkt.Describe()) out.WriteString(pkt.Describe())
fmt.Println(out.String()) fmt.Println(out.String())
} }
func (stream SimpleStream) Decode(wg *sync.WaitGroup) { func (stream SimpleStream) Decode(wg *sync.WaitGroup) {
for { for {
pkt := NewSimplePacket() pkt := NewSimplePacket()
utterance, err := stream.Read(-1) utterance, err := stream.Read(-1)
if err != nil { if err != nil {
@ -63,7 +62,7 @@ func (stream SimpleStream) Decode(wg *sync.WaitGroup) {
} }
break break
} }
pkt.Payload = utterance.Data pkt.Payload = utterance.Data
pkt.When = utterance.When pkt.When = utterance.When
stream.Display(pkt) stream.Display(pkt)