diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3264963 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +table.cache diff --git a/cmd/shadowsocks-local/local.go b/cmd/shadowsocks-local/local.go index b0ff77c..5650745 100644 --- a/cmd/shadowsocks-local/local.go +++ b/cmd/shadowsocks-local/local.go @@ -277,7 +277,9 @@ func enoughOptions(config *ss.Config) bool { func main() { var configFile, cmdServer string var cmdConfig ss.Config + var printVer bool + flag.BoolVar(&printVer, "version", false, "print version") flag.StringVar(&configFile, "c", "config.json", "specify config file") flag.StringVar(&cmdServer, "s", "", "server address") flag.StringVar(&cmdConfig.Password, "k", "", "password") @@ -287,6 +289,11 @@ func main() { flag.Parse() + if printVer { + ss.PrintVersion() + os.Exit(0) + } + cmdConfig.Server = cmdServer ss.SetDebug(debug) diff --git a/cmd/shadowsocks-server/server.go b/cmd/shadowsocks-server/server.go index f7508e7..107f396 100644 --- a/cmd/shadowsocks-server/server.go +++ b/cmd/shadowsocks-server/server.go @@ -354,7 +354,9 @@ var config *ss.Config func main() { var cmdConfig ss.Config + var printVer bool + flag.BoolVar(&printVer, "version", false, "print version") flag.StringVar(&configFile, "c", "config.json", "specify config file") flag.StringVar(&cmdConfig.Password, "k", "", "password") flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port") @@ -362,6 +364,12 @@ func main() { flag.BoolVar((*bool)(&debug), "d", false, "print debug message") flag.Parse() + + if printVer { + ss.PrintVersion() + os.Exit(0) + } + ss.SetDebug(debug) var err error diff --git a/shadowsocks/util.go b/shadowsocks/util.go index 3557025..c390c7e 100644 --- a/shadowsocks/util.go +++ b/shadowsocks/util.go @@ -2,9 +2,15 @@ package shadowsocks import ( "errors" + "fmt" "os" ) +func PrintVersion() { + const version = "0.5" + fmt.Println("shadowsocks-go version", version) +} + func IsFileExists(path string) (bool, error) { stat, err := os.Stat(path) if err == nil {