@@ -19,17 +19,17 @@ import (
1919const app string = "mshark"
2020
2121const 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
3434GitHub: https://github.com/shadowy-pycoder/mshark
3535
@@ -79,7 +79,7 @@ func displayInterfaces() error {
7979
8080func 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}
0 commit comments