From 2dcb10500538f559ddd69836271915932127ce4c Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Fri, 30 Aug 2019 22:45:42 +0100 Subject: [PATCH] Allow ProxyMethod to be set as command line argument --- cmd/ck-client/ck-client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/ck-client/ck-client.go b/cmd/ck-client/ck-client.go index a1c4ff3..55e5a13 100644 --- a/cmd/ck-client/ck-client.go +++ b/cmd/ck-client/ck-client.go @@ -232,6 +232,7 @@ func main() { var remoteHost string // The proxy port,should be 443 var remotePort string + var proxyMethod string var udp bool var config string var b64AdminUID string @@ -246,13 +247,13 @@ func main() { remotePort = os.Getenv("SS_REMOTE_PORT") config = os.Getenv("SS_PLUGIN_OPTIONS") } else { - // TODO: allow proxy method to be set here as a flag so different cloak instances may share the same config file flag.StringVar(&localHost, "i", "127.0.0.1", "localHost: Cloak listens to proxy clients on this ip") flag.StringVar(&localPort, "l", "1984", "localPort: Cloak listens to proxy clients on this port") flag.StringVar(&remoteHost, "s", "", "remoteHost: IP of your proxy server") flag.StringVar(&remotePort, "p", "443", "remotePort: proxy port, should be 443") flag.BoolVar(&udp, "u", false, "udp: set this flag if the underlying proxy is using UDP protocol") flag.StringVar(&config, "c", "ckclient.json", "config: path to the configuration file or options seperated with semicolons") + flag.StringVar(&proxyMethod, "proxy", "", "proxy: the proxy method's name. It must match exactly with the corresponding entry in server's ProxyBook") flag.StringVar(&b64AdminUID, "a", "", "adminUID: enter the adminUID to serve the admin api") askVersion := flag.Bool("v", false, "Print the version number") printUsage := flag.Bool("h", false, "Print this message") @@ -291,6 +292,10 @@ func main() { log.Fatal(err) } + if proxyMethod != "" { + sta.ProxyMethod = proxyMethod + } + if os.Getenv("SS_LOCAL_HOST") != "" { sta.ProxyMethod = "shadowsocks" } @@ -330,7 +335,7 @@ func main() { network = "TCP" sta.Unordered = false } - log.Infof("Listening on %v %v:%v for proxy clients", network, listeningIP, sta.LocalPort) + log.Infof("Listening on %v %v:%v for %v client", network, listeningIP, sta.LocalPort, sta.ProxyMethod) } if udp {