Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package producer |
||
2 | |||
3 | import ( |
||
4 | "github.com/stefanoj3/dirstalk/pkg/scan" |
||
5 | ) |
||
6 | |||
7 | func NewDictionaryProducer( |
||
|
|||
8 | methods []string, |
||
9 | dictionary []string, |
||
10 | depth int, |
||
11 | ) *DictionaryProducer { |
||
12 | return &DictionaryProducer{ |
||
13 | methods: methods, |
||
14 | dictionary: dictionary, |
||
15 | depth: depth, |
||
16 | } |
||
17 | |||
18 | } |
||
19 | |||
20 | type DictionaryProducer struct { |
||
21 | methods []string |
||
22 | dictionary []string |
||
23 | depth int |
||
24 | } |
||
25 | |||
26 | func (p *DictionaryProducer) Produce() <-chan scan.Target { |
||
27 | targets := make(chan scan.Target, 10) |
||
28 | |||
29 | go func() { |
||
30 | defer close(targets) |
||
31 | |||
32 | for _, entry := range p.dictionary { |
||
33 | for _, method := range p.methods { |
||
34 | targets <- scan.Target{ |
||
35 | Path: entry, |
||
36 | Method: method, |
||
37 | Depth: p.depth, |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | }() |
||
42 | |||
43 | return targets |
||
44 | } |
||
45 |