From ce96db98050703c3658ae3b0cec3dc1083215251 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 10 May 2024 13:03:06 -0400 Subject: WIP --- main.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 6f5333b..86c0919 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,6 @@ import ( "github.com/lrstanley/girc" "github.com/pelletier/go-toml/v2" openai "github.com/sashabaranov/go-openai" - "golang.org/x/net/proxy" "google.golang.org/api/option" ) @@ -242,14 +241,20 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(appConfig.RequestTimeout)*time.Second) defer cancel() - dialer := proxy.FromEnvironment() + httpClient := http.Client{} + allProxy := os.Getenv("ALL_PROXY") + if allProxy != "" { + proxyUrl, err := url.Parse(allProxy) + if err != nil { + client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error())) - transport := http.Transport{ - Dial: dialer.Dial, - } - httpClient := http.Client{ - Transport: &transport, - Timeout: time.Duration(appConfig.RequestTimeout) * time.Second, + return + } + transport := &http.Transport{ + Proxy: http.ProxyURL(proxyUrl), + } + + httpClient.Transport = transport } clientGemini, err := genai.NewClient(ctx, option.WithAPIKey(appConfig.Apikey), option.WithHTTPClient(&httpClient)) -- cgit v1.2.3