Allow ProxyMethod to be set as command line argument

This commit is contained in:
Andy Wang 2019-08-30 22:45:42 +01:00
parent 31898dad63
commit 2dcb105005
1 changed files with 7 additions and 2 deletions

View File

@ -232,6 +232,7 @@ func main() {
var remoteHost string var remoteHost string
// The proxy port,should be 443 // The proxy port,should be 443
var remotePort string var remotePort string
var proxyMethod string
var udp bool var udp bool
var config string var config string
var b64AdminUID string var b64AdminUID string
@ -246,13 +247,13 @@ func main() {
remotePort = os.Getenv("SS_REMOTE_PORT") remotePort = os.Getenv("SS_REMOTE_PORT")
config = os.Getenv("SS_PLUGIN_OPTIONS") config = os.Getenv("SS_PLUGIN_OPTIONS")
} else { } 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(&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(&localPort, "l", "1984", "localPort: Cloak listens to proxy clients on this port")
flag.StringVar(&remoteHost, "s", "", "remoteHost: IP of your proxy server") flag.StringVar(&remoteHost, "s", "", "remoteHost: IP of your proxy server")
flag.StringVar(&remotePort, "p", "443", "remotePort: proxy port, should be 443") 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.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(&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") flag.StringVar(&b64AdminUID, "a", "", "adminUID: enter the adminUID to serve the admin api")
askVersion := flag.Bool("v", false, "Print the version number") askVersion := flag.Bool("v", false, "Print the version number")
printUsage := flag.Bool("h", false, "Print this message") printUsage := flag.Bool("h", false, "Print this message")
@ -291,6 +292,10 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
if proxyMethod != "" {
sta.ProxyMethod = proxyMethod
}
if os.Getenv("SS_LOCAL_HOST") != "" { if os.Getenv("SS_LOCAL_HOST") != "" {
sta.ProxyMethod = "shadowsocks" sta.ProxyMethod = "shadowsocks"
} }
@ -330,7 +335,7 @@ func main() {
network = "TCP" network = "TCP"
sta.Unordered = false 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 { if udp {