Skip to content

Commit

Permalink
Support specifying config file on command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Dec 14, 2012
1 parent c62ef73 commit fa17143
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/shadowsocks-local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"errors"
"flag"
ss "github.com/shadowsocks/shadowsocks-go/shadowsocks"
"io"
"log"
Expand Down Expand Up @@ -195,7 +196,11 @@ func run(port, password, server string) {
}

func main() {
config := ss.ParseConfig("config.json")
var configFile string
flag.StringVar(&configFile, "c", "config.json", "specify config file")
flag.Parse()

config := ss.ParseConfig(configFile)
debug = ss.Debug
run(strconv.Itoa(config.LocalPort), config.Password,
config.Server+":"+strconv.Itoa(config.ServerPort))
Expand Down
7 changes: 6 additions & 1 deletion cmd/shadowsocks-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"errors"
"flag"
ss "github.com/shadowsocks/shadowsocks-go/shadowsocks"
"log"
"net"
Expand Down Expand Up @@ -162,7 +163,11 @@ func run(port, password string) {
}

func main() {
config := ss.ParseConfig("config.json")
var configFile string
flag.StringVar(&configFile, "c", "config.json", "specify config file")
flag.Parse()

config := ss.ParseConfig(configFile)
debug = ss.Debug
if len(config.PortPassword) == 0 {
run(strconv.Itoa(config.ServerPort), config.Password)
Expand Down

0 comments on commit fa17143

Please sign in to comment.