Skip to content

Commit 6bd1628

Browse files
added documentation for pcpa packages
1 parent 12165c6 commit 6bd1628

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

cmd/mshark/cli.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ import (
1919
const app string = "mshark"
2020

2121
const usagePrefix string = `
22-
______ __ __
23-
/ \ | \ | \
24-
______ ____ | $$$$$$\| $$____ ______ ______ | $$ __
22+
______ __ __
23+
/ \ | \ | \
24+
______ ____ | $$$$$$\| $$____ ______ ______ | $$ __
2525
| \ \ | $$___\$$| $$ \ | \ / \ | $$ / \
2626
| $$$$$$\$$$$\ \$$ \ | $$$$$$$\ \$$$$$$\| $$$$$$\| $$_/ $$
27-
| $$ | $$ | $$ _\$$$$$$\| $$ | $$ / $$| $$ \$$| $$ $$
28-
| $$ | $$ | $$| \__| $$| $$ | $$| $$$$$$$| $$ | $$$$$$\
27+
| $$ | $$ | $$ _\$$$$$$\| $$ | $$ / $$| $$ \$$| $$ $$
28+
| $$ | $$ | $$| \__| $$| $$ | $$| $$$$$$$| $$ | $$$$$$\
2929
| $$ | $$ | $$ \$$ $$| $$ | $$ \$$ $$| $$ | $$ \$$\
3030
\$$ \$$ \$$ \$$$$$$ \$$ \$$ \$$$$$$$ \$$ \$$ \$$
31-
32-
Packet Capture Tool by shadowy-pycoder
31+
32+
Packet Capture Tool by shadowy-pycoder
3333
3434
GitHub: https://github.com/shadowy-pycoder/mshark
3535
@@ -79,7 +79,7 @@ func displayInterfaces() error {
7979

8080
func createFile(app, ext string) (*os.File, error) {
8181
path := fmt.Sprintf("./%s_%s.%s", app, time.Now().UTC().Format("20060102_150405"), ext)
82-
f, err := os.OpenFile(filepath.FromSlash(path), os.O_CREATE|os.O_WRONLY, 0644)
82+
f, err := os.OpenFile(filepath.FromSlash(path), os.O_CREATE|os.O_WRONLY, 0o644)
8383
if err != nil {
8484
return nil, fmt.Errorf("failed to open file: %v", err)
8585
}
@@ -92,10 +92,14 @@ func root(args []string) error {
9292
flags := flag.NewFlagSet(app, flag.ExitOnError)
9393
iface := flags.String("i", "any", "The name of the network interface. Example: eth0")
9494
snaplen := flags.Int("s", 0, "The maximum length of each packet snapshot. Defaults to 65535.")
95-
flags.BoolFunc("p", `Promiscuous mode. This setting is ignored for "any" interface. Defaults to false.`, func(flagValue string) error {
96-
conf.Promisc = true
97-
return nil
98-
})
95+
flags.BoolFunc(
96+
"p",
97+
`Promiscuous mode. This setting is ignored for "any" interface. Defaults to false.`,
98+
func(flagValue string) error {
99+
conf.Promisc = true
100+
return nil
101+
},
102+
)
99103
flags.DurationVar(&conf.Timeout, "t", 0, "The maximum duration of the packet capture process. Example: 5s")
100104
flags.IntVar(&conf.PacketCount, "c", 0, "The maximum number of packets to capture.")
101105
flags.StringVar(&conf.Expr, "e", "", `BPF filter expression. Example: "ip proto tcp".`)
@@ -193,8 +197,5 @@ func root(args []string) error {
193197
}
194198
pw = append(pw, w)
195199
}
196-
if err := ms.OpenLive(&conf, pw...); err != nil {
197-
return err
198-
}
199-
return nil
200+
return ms.OpenLive(&conf, pw...)
200201
}

mpcap/write.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package mpcap implements PCAP Capture File Format
12
package mpcap
23

34
import (

mpcapng/write.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package mpcapng implements PCAP Next Generation (pcapng) Capture File Format
12
package mpcapng
23

34
import (

0 commit comments

Comments
 (0)