handle invalid response from proxy-list; add custom proxies from ENV

This commit is contained in:
Bilal
2020-05-19 19:14:21 +02:00
parent eb6bcb981d
commit 4779f0a91e
3 changed files with 38 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import (
"log"
"os"
"strconv"
"strings"
)
var WebServerConfig structures.WebServerConfig
@@ -43,6 +44,16 @@ func generateClientConfigObject() {
ClientConfig.WorkerServerAddress = getString("WORKER_SERVER_ADDRESS")
ClientConfig.RequestMessagePrefix = getString("REQUEST_MESSAGE_PREFIX")
ClientConfig.ProxyListBaseURL = getString("PROXY_LIST_BASE_URL")
customSOCKS5ProxyListString := getString("CUSTOM_SOCKS5_PROXY_LIST")
customSOCKS5ProxyList := strings.Split(customSOCKS5ProxyListString, ",")
for i := range customSOCKS5ProxyList {
proxy := structures.ProxyServer{Type: "socks5", Address: strings.TrimSpace(customSOCKS5ProxyList[i])}
if len(proxy.Address) > 0 {
ClientConfig.CustomSOCKS5ProxyList = append(ClientConfig.CustomSOCKS5ProxyList, proxy)
}
}
}
func generateServerConfigObject() {
@@ -61,7 +72,8 @@ func initClientConfigDefaultValues() {
defaultClientConfigValues["CLIENT_WAITING_TIMEOUT"] = "60"
defaultClientConfigValues["WORKER_SERVER_ADDRESS"] = "127.0.0.1:1338"
defaultClientConfigValues["REQUEST_MESSAGE_PREFIX"] = "URL "
defaultClientConfigValues["PROXY_LIST_BASE_URL"] = "https://www.proxy-list.download/api/v1/get?type="
defaultClientConfigValues["PROXY_LIST_BASE_URL"] = ""
defaultClientConfigValues["CUSTOM_SOCKS5_PROXY_LIST"] = ""
}
func initServerConfigDefaultValues() {