Skip to content

Commit 4896a96

Browse files
author
shadowy-pycoder
committed
added stdout to supported formats
1 parent af68e03 commit 4896a96

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cmd/mshark/cli.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ Options:
3838
-h Show this help message and exit.
3939
`
4040

41-
var supportedFormats = []string{"txt", "pcap", "pcapng"}
41+
var supportedFormats = []string{"stdout", "txt", "pcap", "pcapng"}
4242

4343
var (
44-
_ ms.PacketWriter = &ms.Writer{}
4544
_ ms.PacketWriter = &mpcap.Writer{}
4645
_ ms.PacketWriter = &mpcapng.Writer{}
4746
)
@@ -109,7 +108,7 @@ func root(args []string) error {
109108
return nil
110109
})
111110
exts := ExtFlag([]string{})
112-
flags.TextVar(&exts, "f", &exts, "File extension(s) to write captured data. Supported formats: txt, pcap, pcapng")
111+
flags.TextVar(&exts, "f", &exts, "File extension(s) to write captured data. Supported formats: stdout, txt, pcap, pcapng")
113112

114113
flags.Usage = func() {
115114
fmt.Print(usagePrefix)
@@ -138,6 +137,12 @@ func root(args []string) error {
138137
if len(exts) != 0 {
139138
for _, ext := range exts {
140139
switch ext {
140+
case "stdout":
141+
w := ms.NewWriter(os.Stdout)
142+
if err := w.WriteHeader(&conf); err != nil {
143+
return err
144+
}
145+
pw = append(pw, w)
141146
case "txt":
142147
f, err := createFile(app, ext)
143148
if err != nil {

mshark.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"golang.org/x/sys/unix"
1515
)
1616

17+
var _ PacketWriter = &Writer{}
18+
1719
type PacketWriter interface {
1820
WritePacket(timestamp time.Time, data []byte) error
1921
}

0 commit comments

Comments
 (0)