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 13, 2023
1 parent 58711c3 commit ce2896f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 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 @@ -56,6 +57,8 @@ func main() {
{Name: "bitcoin-rpcport", Type: "string", Description: "Port to bitcoind RPC (optional).", Default: ""},
{Name: "bitcoin-rpcuser", Type: "string", Description: "Username to bitcoind RPC (optional).", Default: ""},
{Name: "bitcoin-rpcpassword", Type: "string", Description: "Password to bitcoind RPC (optional).", Default: ""},
{Name: "proxy", Type: "string", Description: "Socks proxy (optional)", Default: ""},
{Name: "always-use-proxy", Type: "string", Description: "Always use the proxy when connecting to esploras. (optional)", Default: "true"},
},
RPCMethods: []plugin.RPCMethod{
{
Expand Down Expand Up @@ -172,6 +175,13 @@ func main() {
OnInit: func(p *plugin.Plugin) {
network = p.Network

proxy := p.Args.Get("proxy").String()
always_use_proxy := p.Args.Get("always-use-proxy").String()
if proxy != "" && always_use_proxy == "true" {
os.Setenv("HTTP_PROXY", "socks5://" + proxy)
os.Setenv("HTTPS_PROXY", "socks5://" + 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 ce2896f

Please sign in to comment.