forked from ginuerzh/gost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (51 loc) · 1.56 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
// main
package main
import (
"flag"
//"github.com/ginuerzh/gosocks5"
"log"
"time"
)
var (
Laddr, Saddr, Proxy string
Websocket bool
Shadows bool
SMethod, SPassword string
Method, Password string
CertFile, KeyFile string
)
func init() {
printVersion()
flag.StringVar(&Proxy, "P", "", "proxy for forward")
flag.StringVar(&Saddr, "S", "", "the server that connecting to")
flag.StringVar(&Laddr, "L", ":8080", "listen address")
flag.StringVar(&Method, "m", "", "tunnel cipher method")
flag.StringVar(&Password, "p", "[email protected]", "tunnel cipher password")
flag.StringVar(&CertFile, "cert", "", "cert file for tls")
flag.StringVar(&KeyFile, "key", "", "key file for tls")
flag.BoolVar(&Shadows, "ss", false, "run as shadowsocks server")
flag.BoolVar(&Websocket, "ws", false, "use websocket for tunnel")
flag.StringVar(&SMethod, "sm", "rc4-md5", "shadowsocks cipher method")
flag.StringVar(&SPassword, "sp", "[email protected]", "shadowsocks cipher password")
flag.Parse()
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
var (
spool = NewMemPool(1024, 120*time.Minute, 1024) // 1k size buffer pool
mpool = NewMemPool(16*1024, 60*time.Minute, 512) // 16k size buffer pool
lpool = NewMemPool(32*1024, 30*time.Minute, 256) // 32k size buffer pool
)
func main() {
//log.Fatal(gost.Run())
if len(Saddr) == 0 {
var server Server
if Websocket {
server = &WSServer{Addr: Laddr}
} else {
server = &Socks5Server{Addr: Laddr}
}
log.Fatal(server.ListenAndServe())
return
}
log.Fatal(listenAndServe(Laddr, cliHandle))
}