Skip to content

Commit 2eb08b6

Browse files
committed
Support and env vars for LLM request via proxies.
Fixes #73
1 parent c04c59e commit 2eb08b6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fix reasoning titles in thoughts blocks for openai-responses.
66
- Fix hanging LSP diagnostics requests
77
- Add `lspTimeoutSeconds` to config
8+
- Support `HTTP_PROXY` and `HTTPS_PROXY` env vars for LLM request via proxies. #73
89

910
## 0.32.4
1011

src/eca/main.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
[clojure.string :as string]
88
[eca.config :as config]
99
[eca.logger :as logger]
10-
[eca.server :as server]))
10+
[eca.server :as server]
11+
[eca.proxy :as proxy]))
1112

1213
(set! *warn-on-reflection* true)
1314

@@ -89,6 +90,7 @@
8990

9091
(defn ^:private handle-action!
9192
[action options]
93+
(proxy/load!)
9294
(when (= "server" action)
9395
(alter-var-root #'logger/*level* (constantly (keyword (:log-level options))))
9496
(let [finished @(server/run-io-server! (:verbose options))]

src/eca/proxy.clj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(ns eca.proxy
2+
(:require
3+
[eca.config :as config])
4+
(:import
5+
[java.net URL]))
6+
7+
(set! *warn-on-reflection* true)
8+
9+
(defn load! []
10+
(when-let [^URL url (try (some-> (not-empty (config/get-env "HTTP_PROXY"))
11+
(URL.))
12+
(catch Exception _ nil))]
13+
(System/setProperty "http.proxyHost" (.getHost url))
14+
(let [port (.getPort url)]
15+
(when (not= -1 port)
16+
(System/setProperty "http.proxyPort" (.getPort url)))))
17+
(when-let [^URL url (try (some-> (not-empty (config/get-env "HTTPS_PROXY"))
18+
(URL.))
19+
(catch Exception _ nil))]
20+
(System/setProperty "https.proxyHost" (.getHost url))
21+
(let [port (.getPort url)]
22+
(when (not= -1 port)
23+
(System/setProperty "https.proxyPort" (.getPort url))))))

0 commit comments

Comments
 (0)