/
main.go
63 lines (52 loc) · 1.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"fmt"
"log"
"os"
"github.com/phaxio/filterpcap/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func main() {
app := cli.NewApp()
app.Name = "filterpcap"
app.Version = "0.1"
app.Usage = "filterpcap someFile.pcap [options]"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "to",
Usage: "Extract calls to a certain number",
},
cli.StringFlag{
Name: "callId",
Usage: "Extract call with a specific SIP call ID",
},
cli.StringFlag{
Name: "outputDirectory, d",
Usage: "Directory used to output filtered files",
Value: "./",
},
cli.BoolFlag {
Name: "debug",
Usage: "Output debugging information",
},
}
app.Action = func(c *cli.Context) {
runTestZone()
}
app.Run(os.Args)
}
func mainAction(c *cli.Context){
if len(c.Args()) == 0 {
fmt.Println("You must specify a pcap filename")
return
}
if c.String("to") != "" {
Filters = append(Filters, PcapFilter{filterType: "to", value: c.String("to")})
}
if c.String("callId") != "" {
Filters = append(Filters, PcapFilter{filterType: "callId", value: c.String("callId")})
}
err := createFilteredPcaps(c.Args()[0], c.String("outputDirectory"), c.Bool("debug"))
if err != nil {
log.Fatal(err)
}
}