forked from kevwan/tproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 971 Bytes
/
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
package main
import (
"flag"
"fmt"
"os"
"github.com/fatih/color"
)
var settings Settings
func main() {
var (
localPort = flag.Int("p", 0, "Local port to listen on")
localHost = flag.String("l", "localhost", "Local address to listen on")
remote = flag.String("r", "", "Remote address (host:port) to connect")
delay = flag.Duration("d", 0, "the delay to relay packets")
protocol = flag.String("t", "", "The type of protocol, currently support grpc")
quiet = flag.Bool("q", false,
"Quiet mode, only prints connection open/close and stats, default false")
)
flag.Parse()
saveSettings(*localHost, *localPort, *remote, *delay, *protocol, *quiet)
if settings.RemoteHost == "" {
fmt.Fprintln(os.Stderr, color.HiRedString("[x] Remote host required"))
flag.PrintDefaults()
os.Exit(1)
}
if err := startListener(); err != nil {
fmt.Fprintln(os.Stderr, color.HiRedString("[x] Failed to start listener: %v", err))
os.Exit(1)
}
}