• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nagayon-935 / DrawlScan / 15348316773

30 May 2025 01:52PM UTC coverage: 0.0%. Remained the same
15348316773

push

github

web-flow
Merge pull request #2 from nagayon-935/releases/v0.2.0

Releases/v0.2.0

0 of 162 new or added lines in 6 files covered. (0.0%)

9 existing lines in 1 file now uncovered.

0 of 514 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/handler/option_handler.go
1
package handler
2

3
import (
4
        "fmt"
5
        "reflect"
6

7
        flag "github.com/spf13/pflag"
8
)
9

10
type analysisOption struct {
11
        Geoip  bool
12
        Filter string
13
}
14

15
type captureOption struct {
16
        Count int
17
        Time  int
18
}
19

20
type generalOption struct {
21
        Help    bool
22
        Version bool
23
}
24

25
type ioOption struct {
26
        InterfaceName string
27
        OutputFile    string
28
}
29

30
type visualizationOption struct {
31
        Ascii   bool
32
        NoAscii bool
33
}
34

35
type options struct {
36
        Analysis      *analysisOption
37
        Capture       *captureOption
38
        General       *generalOption
39
        Io            *ioOption
40
        Visualization *visualizationOption
41
}
42

NEW
43
func HelpMessage() string {
×
44
        return `Usage: drawlscan [OPTIONS]
×
45

×
46
OPTIONS:
×
47
    -c, --count <NUM>              Capture only a specified number of packets
×
NEW
48
    -f, --filter <REGX>            Filter packets using a BPF (Berkeley Packet Filter) expression.
×
NEW
49
                                   You can specify filters such as:
×
NEW
50
                                     - ip src 192.168.1.1
×
NEW
51
                                     - ip dst 192.168.1.2
×
NEW
52
                                     - ip host 192.168.1.1 and ip host 192.168.1.2
×
NEW
53
                                     - tcp port 80
×
NEW
54
                                     - udp port 53
×
NEW
55
                                     - icmp or icmp6
×
NEW
56
                                     - vlan 100
×
NEW
57
                                     - ip host 192.168.1.1 and tcp port 80
×
58
    -g, --geoip                    Show GeoIP information for source and destination IP addresses
×
59
    -h, --help                     Display this help message
×
60
    -i, --interface <INTERFACE>    Specify the network interface to capture packets from (e.g., eth0, wlan0)
×
61
    -o, --output <FILE>            Save the captured packets to a file in PCAP format
×
NEW
62
    -t, --time <TIME>              Stop capturing after a specified number of seconds
×
63
    -v, --version                  Show version information
×
64
    --no-ascii                     Disable ASCII-art output
×
65
`
×
66
}
×
67

68
func buildFlagSet() (*flag.FlagSet, *options) {
×
69
        opts := &options{
×
70
                Capture:       &captureOption{},
×
71
                Analysis:      &analysisOption{},
×
72
                Visualization: &visualizationOption{},
×
73
                General:       &generalOption{},
×
74
                Io:            &ioOption{},
×
75
        }
×
76

×
77
        flags := flag.NewFlagSet("drawlscan", flag.ContinueOnError)
×
NEW
78
        flags.Usage = func() { fmt.Println(HelpMessage()) }
×
79

80
        flags.BoolVarP(&opts.Analysis.Geoip, "geoip", "g", false, "Show GeoIP information for source and destination IP addresses")
×
NEW
81
        flags.StringVarP(&opts.Analysis.Filter, "filter", "f", "", "Filter packets")
×
82

×
NEW
83
        flags.IntVarP(&opts.Capture.Count, "count", "c", -1, "Capture only a specified number of packets")
×
NEW
84
        flags.IntVarP(&opts.Capture.Time, "time", "t", -1, "Stop capturing after a specified number of seconds")
×
85

×
86
        flags.BoolVarP(&opts.General.Help, "help", "h", false, "Help message")
×
87
        flags.BoolVarP(&opts.General.Version, "version", "v", false, "Version information")
×
88

×
89
        flags.StringVarP(&opts.Io.InterfaceName, "interface", "i", "", "Specify the network interface to capture packets from (e.g., eth0, wlan0)")
×
90
        flags.StringVarP(&opts.Io.OutputFile, "output", "o", "", " Save the captured packets to a file in PCAP format")
×
91

×
92
        flags.BoolVar(&opts.Visualization.NoAscii, "no-ascii", false, "Disable ASCII-art output")
×
93

×
94
        return flags, opts
×
95
}
96

97
func collectFieldMap(value reflect.Value, optionMap map[string]interface{}) {
×
98
        if value.Kind() == reflect.Ptr {
×
99
                value = value.Elem()
×
100
        }
×
101
        valueType := value.Type()
×
102

×
103
        fields := reflect.VisibleFields(valueType)
×
104
        for _, field := range fields {
×
105
                fieldValue := value.FieldByIndex(field.Index)
×
106
                key := field.Name
×
107
                if fieldValue.Kind() == reflect.Struct || (fieldValue.Kind() == reflect.Ptr && !fieldValue.IsNil() && fieldValue.Elem().Kind() == reflect.Struct) {
×
108
                        collectFieldMap(fieldValue, optionMap)
×
109
                } else {
×
110
                        optionMap[key] = fieldValue.Interface()
×
111
                }
×
112
        }
113
}
114

NEW
115
func Options(optArgs []string) map[string]interface{} {
×
116
        flags, options := buildFlagSet()
×
117
        flags.Parse(optArgs[1:])
×
118
        optionMap := make(map[string]interface{})
×
119
        collectFieldMap(reflect.ValueOf(options), optionMap)
×
120
        return optionMap
×
121
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc