Skip to content

Commit 8c00df1

Browse files
cosmetic changes to mshark
1 parent 127edd9 commit 8c00df1

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

layers/dns.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ func svcparamkeydesc(key uint16) string {
589589
svcdesc = "ohttp"
590590
case 9:
591591
svcdesc = "tls-supported-groups"
592+
default:
593+
svcdesc = "Unknown"
592594
}
593595
return svcdesc
594596
}

layers/layers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Layer interface {
4747
}
4848

4949
func GetNextLayer(layer string) Layer {
50+
// TODO (shadowy-pycoder): add this to NextLayer, choose by ports, parse, use fallback on error
5051
switch layer {
5152
case "ETH":
5253
return &EthernetFrame{}

mshark.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net"
99
"os"
1010
"os/signal"
11+
"strings"
1112
"time"
1213

1314
"github.com/mdlayher/packet"
@@ -18,13 +19,14 @@ import (
1819

1920
const unixEthPAll int = 0x03
2021

21-
var colorMap = map[int]string{
22+
var colorMap = map[int]string{ // TODO (shadowy-pycoder): add colors from shadowy-pycoder/colors
2223
0: "\033[37m",
2324
1: "\033[36m",
2425
2: "\033[32m",
2526
3: "\033[33m",
2627
4: "\033[35m",
2728
}
29+
var packetDelimeter = "\033[37m" + strings.Repeat("─", 66) + "\033[0m"
2830

2931
var _ PacketWriter = &Writer{}
3032

@@ -80,8 +82,8 @@ func (mw *Writer) printPacket(layer layers.Layer, layerNum int) {
8082
// Timestamps are to be generated by the calling code.
8183
func (mw *Writer) WritePacket(timestamp time.Time, data []byte) error {
8284
mw.packets++
83-
fmt.Fprintf(mw.w, "- Packet: %d Timestamp: %s\n", mw.packets, timestamp.Format("2006-01-02T15:04:05-0700"))
84-
fmt.Fprintln(mw.w, "==================================================================")
85+
fmt.Fprintf(mw.w, "- Packet: %d Timestamp: %s\n", mw.packets, timestamp.Format("2006-01-02T15:04:05.000000-0700"))
86+
fmt.Fprintln(mw.w, packetDelimeter)
8587
next := layers.GetNextLayer("ETH")
8688
if next == nil {
8789
return nil

0 commit comments

Comments
 (0)