Skip to content

Commit

Permalink
Add version printing.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Dec 25, 2012
1 parent dbaf605 commit b8d1fea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
table.cache
7 changes: 7 additions & 0 deletions cmd/shadowsocks-local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -287,6 +289,11 @@ func main() {

flag.Parse()

if printVer {
ss.PrintVersion()
os.Exit(0)
}

cmdConfig.Server = cmdServer
ss.SetDebug(debug)

Expand Down
8 changes: 8 additions & 0 deletions cmd/shadowsocks-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,22 @@ 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")
flag.IntVar(&cmdConfig.Timeout, "t", 60, "connection timeout (in seconds)")
flag.BoolVar((*bool)(&debug), "d", false, "print debug message")

flag.Parse()

if printVer {
ss.PrintVersion()
os.Exit(0)
}

ss.SetDebug(debug)

var err error
Expand Down
6 changes: 6 additions & 0 deletions shadowsocks/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b8d1fea

Please sign in to comment.