-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
58 lines (49 loc) · 1.75 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
package main
import (
"log"
"os"
"time"
"github.com/jessevdk/go-flags"
)
type Options struct {
ServerAddr string `short:"s" description:"server address" required:"true"`
ServerPort int `short:"p" description:"server port" required:"false" default:"8388"`
LocalAddr string `short:"b" description:"local binding address" required:"false" default:"127.0.0.1"`
LocalPort int `short:"l" description:"local port" required:"false" default:"1080"`
Password string `short:"k" description:"password" required:"true"`
Method string `short:"m" description:"encryption method" required:"false" default:"aes-256-cfb"`
Obfs string `short:"o" description:"obfsplugin" required:"false" default:"http_simple"`
ObfsParam string `long:"op" description:"obfs param" required:"false"`
Protocol string `short:"O" description:"protocol" required:"false" default:"origin"`
ProtocolParam string `long:"Op" description:"protocol param" required:"false"`
SocketTimeout int `short:"t" description:"socket timeout in seconds" required:"false" default:"10"`
ForwardProxy string `short:"f" description:"socks5 forward proxy address. example: 127.0.0.1:8080" required:"false"`
VerboseMode bool `short:"v" description:"verbose mode"`
}
func main() {
var opts Options
parser := flags.NewParser(&opts, flags.Default)
_, err := parser.Parse()
if err != nil {
os.Exit(1)
}
ssrClient, err := NewSSRClient(
opts.ServerAddr,
opts.ServerPort,
opts.LocalAddr,
opts.LocalPort,
opts.Password,
opts.Method,
opts.Obfs,
opts.ObfsParam,
opts.Protocol,
opts.ProtocolParam,
opts.ForwardProxy,
time.Duration(opts.SocketTimeout)*time.Second,
opts.VerboseMode,
)
if err != nil {
log.Fatalln(err)
}
ssrClient.ListenAndServe()
}