From c5009ede50dcefdc0e614709819190b810cb69f4 Mon Sep 17 00:00:00 2001 From: Otto Sabart Date: Tue, 11 Apr 2023 21:00:00 +0200 Subject: [PATCH] honor the cln proxy settings --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.go b/main.go index 52c2c37..7f63a36 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "os" "fmt" "math/rand" @@ -64,6 +65,7 @@ func main() { "Get the bitcoin block at a given height", "", func(p *plugin.Plugin, params plugin.Params) (resp interface{}, errCode int, err error) { + height := params.Get("height").Int() blockUnavailable := map[string]interface{}{ @@ -172,6 +174,17 @@ func main() { OnInit: func(p *plugin.Plugin) { network = p.Network + proxy := p.Configuration.Get("proxy") + always_use_proxy := p.Configuration.Get("always_use_proxy").Bool() + + if proxy.Exists() && always_use_proxy { + socks_proxy := "socks5://" + proxy.Get("address").String() + ":" + proxy.Get("port").String() + p.Logf("using proxy: %s", socks_proxy) + + os.Setenv("HTTP_PROXY", socks_proxy) + os.Setenv("HTTPS_PROXY", socks_proxy) + } + // we will try to use a local bitcoind user := p.Args.Get("bitcoin-rpcuser").String() pass := p.Args.Get("bitcoin-rpcpassword").String()