From efb52c6b429d6e3a3c1134205f10e71adacdb9e7 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 1 May 2023 16:47:53 +0800 Subject: [PATCH] remove excessive proxy stuff --- internal/chatgpt/request.go | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/internal/chatgpt/request.go b/internal/chatgpt/request.go index e177eef..326fe88 100644 --- a/internal/chatgpt/request.go +++ b/internal/chatgpt/request.go @@ -1,12 +1,9 @@ package chatgpt import ( - "bufio" "bytes" "encoding/json" - "math/rand" "os" - "strings" typings "freechatgpt/internal/typings" @@ -31,41 +28,10 @@ var ( API_REVERSE_PROXY = os.Getenv("API_REVERSE_PROXY") ) -func init() { - // Check for proxies.txt - if _, err := os.Stat("proxies.txt"); err == nil { - // Each line is a proxy, put in proxies array - file, _ := os.Open("proxies.txt") - defer file.Close() - scanner := bufio.NewScanner(file) - for scanner.Scan() { - // Split line by : - proxy := scanner.Text() - proxy_parts := strings.Split(proxy, ":") - if len(proxy_parts) == 2 { - proxy = "socks5://" + proxy - } else if len(proxy_parts) == 4 { - proxy = "socks5://" + proxy_parts[2] + ":" + proxy_parts[3] + "@" + proxy_parts[0] + ":" + proxy_parts[1] - } else { - continue - } - proxies = append(proxies, proxy) - } - } -} - -func random_int(min int, max int) int { - return min + rand.Intn(max-min) -} - func SendRequest(message typings.ChatGPTRequest, access_token string) (*http.Response, error) { - if http_proxy != "" && len(proxies) > 0 { + if http_proxy != "" { client.SetProxy(http_proxy) } - // Take random proxy from proxies.txt - if len(proxies) > 0 { - client.SetProxy(proxies[random_int(0, len(proxies)-1)]) - } apiUrl := "https://chat.openai.com/backend-api/conversation" if API_REVERSE_PROXY != "" {