MCPcopy Index your code
hub / github.com/shadowsocks/v2ray-plugin / parseEnv

Function parseEnv

args.go:67–102  ·  view source on GitHub ↗

Parse SS_PLUGIN options from environment variables

()

Source from the content-addressed store, hash-verified

65
66// Parse SS_PLUGIN options from environment variables
67func 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//

Callers 1

startV2RayFunction · 0.85

Calls 2

parsePluginOptionsFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected