Parse SS_PLUGIN options from environment variables
()
| 65 | |
| 66 | // Parse SS_PLUGIN options from environment variables |
| 67 | func parseEnv() (opts Args, err error) { |
| 68 | opts = make(Args) |
| 69 | ss_remote_host := os.Getenv("SS_REMOTE_HOST") |
| 70 | ss_remote_port := os.Getenv("SS_REMOTE_PORT") |
| 71 | ss_local_host := os.Getenv("SS_LOCAL_HOST") |
| 72 | ss_local_port := os.Getenv("SS_LOCAL_PORT") |
| 73 | if len(ss_remote_host) == 0 { |
| 74 | return |
| 75 | } |
| 76 | if len(ss_remote_port) == 0 { |
| 77 | return |
| 78 | } |
| 79 | if len(ss_local_host) == 0 { |
| 80 | return |
| 81 | } |
| 82 | if len(ss_local_port) == 0 { |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | opts.Add("remoteAddr", ss_remote_host) |
| 87 | opts.Add("remotePort", ss_remote_port) |
| 88 | opts.Add("localAddr", ss_local_host) |
| 89 | opts.Add("localPort", ss_local_port) |
| 90 | |
| 91 | ss_plugin_options := os.Getenv("SS_PLUGIN_OPTIONS") |
| 92 | if len(ss_plugin_options) > 0 { |
| 93 | other_opts, err := parsePluginOptions(ss_plugin_options) |
| 94 | if err != nil { |
| 95 | return nil, err |
| 96 | } |
| 97 | for k, v := range other_opts { |
| 98 | opts[k] = v |
| 99 | } |
| 100 | } |
| 101 | return opts, nil |
| 102 | } |
| 103 | |
| 104 | // Parse a name–value mapping as from SS_PLUGIN_OPTIONS. |
| 105 | // |
no test coverage detected