diff --git a/accounting/config.go b/accounting/config.go index 972c8d9e..2edc3fc0 100644 --- a/accounting/config.go +++ b/accounting/config.go @@ -108,7 +108,7 @@ type CommonConfig struct { func NewOnChainConfig(ctx context.Context, lnd lndclient.LndServices, startTime, endTime time.Time, disableFiat bool, txLookup fees.GetDetailsFunc, fiatBackend fiat.PriceBackend, granularity *fiat.Granularity, - categories []CustomCategory) *OnChainConfig { + categories []CustomCategory, socksProxy string) *OnChainConfig { var getFee func(chainhash.Hash) (btcutil.Amount, error) if txLookup != nil { @@ -140,6 +140,7 @@ func NewOnChainConfig(ctx context.Context, lnd lndclient.LndServices, startTime, FiatBackend: fiatBackend, Granularity: granularity, Categories: categories, + SocksProxy: socksProxy, }, GetFee: getFee, } @@ -152,7 +153,7 @@ func NewOffChainConfig(ctx context.Context, lnd lndclient.LndServices, maxInvoices, maxPayments, maxForwards uint64, ownPubkey route.Vertex, startTime, endTime time.Time, disableFiat bool, fiatBackend fiat.PriceBackend, granularity *fiat.Granularity, - categories []CustomCategory) *OffChainConfig { + categories []CustomCategory, socksProxy string) *OffChainConfig { return &OffChainConfig{ ListInvoices: func() ([]lndclient.Invoice, error) { @@ -186,6 +187,7 @@ func NewOffChainConfig(ctx context.Context, lnd lndclient.LndServices, FiatBackend: fiatBackend, Granularity: granularity, Categories: categories, + SocksProxy: socksProxy, }, } } diff --git a/cmd/frcli/fiat_estimate.go b/cmd/frcli/fiat_estimate.go index 8db2917e..23bd5170 100644 --- a/cmd/frcli/fiat_estimate.go +++ b/cmd/frcli/fiat_estimate.go @@ -30,7 +30,7 @@ var fiatEstimateCommand = cli.Command{ cli.StringFlag{ Name: "fiat_backend", Usage: "fiat backend to be used. Options include: " + - "'coincap' (default) and 'coindesk'", + "'coincap' (default if no proxy is set) and 'coindesk' (default if a proxy is set)", }, }, Action: queryFiatEstimate, diff --git a/config.go b/config.go index 2e736c52..2ee64412 100644 --- a/config.go +++ b/config.go @@ -123,6 +123,9 @@ type Config struct { //nolint:maligned // Bitcoin is the configuration required to connect to a bitcoin node. Bitcoin *chain.BitcoinConfig `group:"bitcoin" namespace:"bitcoin"` + + // SocksProxy is the address to use as a socks proxy for http requests. No proxy is used if the value is empty. + SocksProxy string `long:"proxy" description:"Address to be used as the socks proxy for HTTP requests."` } // DefaultConfig returns all default values for the Config struct. diff --git a/faraday.go b/faraday.go index 308e6bd0..316902d4 100644 --- a/faraday.go +++ b/faraday.go @@ -79,6 +79,7 @@ func Main() error { RestClientConfig: restClientCreds, FaradayDir: config.FaradayDir, MacaroonPath: config.MacaroonPath, + SocksProxy: config.SocksProxy, } // If the client chose to connect to a bitcoin client, get one now. diff --git a/frdrpc/node_audit.go b/frdrpc/node_audit.go index bae9ea60..e60eac06 100644 --- a/frdrpc/node_audit.go +++ b/frdrpc/node_audit.go @@ -72,7 +72,7 @@ func parseNodeAuditRequest(ctx context.Context, cfg *Config, ctx, cfg.Lnd, uint64(maxInvoiceQueries), uint64(maxPaymentQueries), uint64(maxForwardQueries), pubkey, start, end, req.DisableFiat, fiatBackend, granularity, - offChainCategories, + offChainCategories, cfg.SocksProxy, ) // If we have a chain connection, set our tx lookup function. Otherwise @@ -88,6 +88,7 @@ func parseNodeAuditRequest(ctx context.Context, cfg *Config, onChain := accounting.NewOnChainConfig( ctx, cfg.Lnd, start, end, req.DisableFiat, feeLookup, fiatBackend, granularity, onChainCategories, + cfg.SocksProxy, ) return onChain, offChain, nil diff --git a/frdrpc/rpcserver.go b/frdrpc/rpcserver.go index fd6a07c9..e4f187e0 100644 --- a/frdrpc/rpcserver.go +++ b/frdrpc/rpcserver.go @@ -140,6 +140,9 @@ type Config struct { // that is created automatically. This path normally is within // FaradayDir unless otherwise specified by the user. MacaroonPath string + + // SocksProxy that if set is the url to use to proxy http requests. + SocksProxy string } // NewRPCServer returns a server which will listen for rpc requests on the @@ -443,7 +446,7 @@ func (s *RPCServer) ExchangeRate(ctx context.Context, } prices, err := fiat.GetPrices( - ctx, timestamps, fiatBackend, *granularity, "", + ctx, timestamps, fiatBackend, *granularity, s.cfg.SocksProxy, ) if err != nil { return nil, err