Skip to content

Commit

Permalink
honor the cln proxy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
seberm committed Apr 14, 2023
1 parent 58711c3 commit c5009ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"os"
"fmt"
"math/rand"

Expand Down Expand Up @@ -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{}{
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c5009ed

Please sign in to comment.