-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (38 loc) · 1.15 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
package main
import (
"flag"
"fmt"
"log"
"github.com/sifatulrabbi/shadowtracker/internals/logswriter"
"github.com/sifatulrabbi/shadowtracker/internals/tcpinterceptor"
)
func main() {
var (
logger *logswriter.Logger
action = flag.String("action", "start", "Enter the action you want to perform")
logsDir = flag.String("logsdir", "/var/log/shadowtracker", "Enter the logs directory path")
target = flag.String("target", "", "Enter the port to listen to")
forward = flag.String("forward", "", "Enter the traffic forwarding port")
)
flag.Parse()
logger = logswriter.NewLogger(&logswriter.NewLoggerOptions{Destination: *logsDir})
if *target == "" || *forward == "" {
log.Panicln("'-target' and '-forward' is required")
}
switch *action {
case "start":
startInterceptor(*target, *forward, logger)
break
default:
log.Panicln("Please enter a valid action")
break
}
}
func startInterceptor(target, forward string, logger *logswriter.Logger) {
log.Println("Starting shadowtracker...")
if err := tcpinterceptor.NewTCPListener(target, forward, logger); err != nil {
log.Panicln(err)
} else {
fmt.Println("shadowtracker stopped")
}
}