aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-05-10 17:03:06 +0000
committerterminaldweller <devi@terminaldweller.com>2024-05-10 17:03:06 +0000
commitce96db98050703c3658ae3b0cec3dc1083215251 (patch)
treee0126685a4184f6c78802a740a25e2885dc5d1ac
parentWIP (diff)
downloadmilla-ce96db98050703c3658ae3b0cec3dc1083215251.tar.gz
milla-ce96db98050703c3658ae3b0cec3dc1083215251.zip
WIP
-rw-r--r--main.go21
1 files 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))