-
Notifications
You must be signed in to change notification settings - Fork 90
/
main.go
50 lines (40 loc) · 993 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
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/hidu/pproxy/serve"
)
var configPath = flag.String("conf", "./conf/pproxy.conf", "pproxy's config file")
var port = flag.Int("port", 0, "proxy port")
var vv = flag.Bool("vv", false, "debug,log request with more detail")
var showConf = flag.Bool("demo_conf", false, "show default conf")
var version = flag.Bool("v", false, "show version")
func init() {
df := flag.Usage
flag.Usage = func() {
df()
fmt.Fprintln(os.Stderr, "\n HTTP protocol analysis tool\n https://github.com/hidu/pproxy/\n")
}
}
func main() {
flag.Parse()
if *showConf {
demoConf := serve.GetDemoConf()
fmt.Println(demoConf)
os.Exit(0)
}
if *version {
fmt.Println("pproxy version:", serve.GetVersion())
os.Exit(0)
}
log.SetFlags(log.Lshortfile | log.LstdFlags | log.Ldate)
ser, err := serve.NewProxyServe(*configPath, *port)
if err != nil {
fmt.Println("start pproxy failed", err)
os.Exit(2)
}
ser.Debug = *vv
ser.Start()
}