-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.go
46 lines (41 loc) · 952 Bytes
/
env.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package common
import (
"os"
"strings"
)
var (
// is debug
IS_DEBUG_MODE bool
// socks
SOCKS_URL string
SOCKS_USER string
SOCKS_PWD string
// user token
USER_TOKEN_ENV_NAME_PREFIX = "Go_Proxy_BingAI_USER_TOKEN"
USER_TOKEN_LIST []string
// 访问权限密钥,可选
AUTH_KEY string
AUTH_KEY_COOKIE_NAME = "BingAI_Auth_Key"
)
func init() {
initEnv()
initUserToken()
}
func initEnv() {
// is debug
IS_DEBUG_MODE = os.Getenv("Go_Proxy_BingAI_Debug") != ""
// socks
SOCKS_URL = os.Getenv("Go_Proxy_BingAI_SOCKS_URL")
SOCKS_USER = os.Getenv("Go_Proxy_BingAI_SOCKS_USER")
SOCKS_PWD = os.Getenv("Go_Proxy_BingAI_SOCKS_PWD")
// auth
AUTH_KEY = os.Getenv("Go_Proxy_BingAI_AUTH_KEY")
}
func initUserToken() {
for _, env := range os.Environ() {
if strings.HasPrefix(env, USER_TOKEN_ENV_NAME_PREFIX) {
parts := strings.SplitN(env, "=", 2)
USER_TOKEN_LIST = append(USER_TOKEN_LIST, parts[1])
}
}
}