diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-05-10 17:03:06 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-05-10 17:03:06 +0000 |
commit | ce96db98050703c3658ae3b0cec3dc1083215251 (patch) | |
tree | e0126685a4184f6c78802a740a25e2885dc5d1ac | |
parent | WIP (diff) | |
download | milla-ce96db98050703c3658ae3b0cec3dc1083215251.tar.gz milla-ce96db98050703c3658ae3b0cec3dc1083215251.zip |
WIP
-rw-r--r-- | main.go | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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)) |