Pass client configuration as an argument

The ClientCommonConf, configuration file path, and server UDP port are
now passed around as arguments instead of being shared between
components as global variables. This allows for multiple clients to
exist in the same process, and allows client.Session to be used as a
library more easily.
This commit is contained in:
Tyler Compton
2019-08-20 13:53:27 -07:00
parent f999c8a87e
commit 666f122a72
19 changed files with 162 additions and 164 deletions

View File

@@ -52,7 +52,7 @@ var stcpCmd = &cobra.Command{
Use: "stcp",
Short: "Run frpc with a single stcp proxy",
RunE: func(cmd *cobra.Command, args []string) error {
err := parseClientCommonCfg(CfgFileTypeCmd, "")
clientCfg, err := parseClientCommonCfg(CfgFileTypeCmd, "")
if err != nil {
fmt.Println(err)
os.Exit(1)
@@ -104,7 +104,7 @@ var stcpCmd = &cobra.Command{
os.Exit(1)
}
err = startService(proxyConfs, visitorConfs)
err = startService(clientCfg, proxyConfs, visitorConfs, "")
if err != nil {
fmt.Println(err)
os.Exit(1)