-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi: add socks proxy flag #117
Conversation
@@ -91,17 +93,56 @@ var priceBackendNames = map[PriceBackend]string{ | |||
CoinDeskPriceBackend: "coindesk", | |||
} | |||
|
|||
var priceBackendProxySupport = map[PriceBackend]bool{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on doing a config map instead of the 2 separate priceBackendNames
and priceBackendProxySupport
maps? So something like this:
type backendsConfig struct {
name string
proxySupport bool
}
var priceBackendsConfig = map[PriceBackend]backendsConfig {
UnknownPriceBackend: {
name: "unknown",
proxySupport: false,
},
CoinCapPriceBackend: {
name: "coincap",
proxySupport: false,
},
CoinDeskPriceBackend: {
name: "coindesk",
proxySupport: true,
},
}
f3e9a5f
to
761b463
Compare
This commit adds support for the coindesk backends to be initialized with a socks proxy if one is provided.
This commit adds a socks proxy option to the rpc config. This option is set using the SocksProxy flag in the main faraday config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, goods are as advertised!
Just a unit test then this is gg.
fiat/prices.go
Outdated
// Check that the proxy flag is not set for a price backend that does | ||
// not support requests through a socks proxy. | ||
if proxy != "" && !priceBackendProxySupport[backend] { | ||
return nil, errors.New("can't use a socks proxy for the " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add the backend here for a friendlier user err
// String returns the string representation of a price backend. | ||
func (p PriceBackend) String() string { | ||
return priceBackendNames[p] | ||
} | ||
|
||
// NewPriceSource returns a PriceSource which can be used to query price | ||
// data. | ||
func NewPriceSource(backend PriceBackend, granularity *Granularity) ( | ||
*PriceSource, error) { | ||
func NewPriceSource(backend PriceBackend, granularity *Granularity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a unit test for this? Just to assert that we error out with the correct combinations etc.
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting to the point where it may be worth pulling all the fiat params out into a FiatConfig
.
But I think we can kick that can down the road for now, if we hit > 3 params then it's time :')
@ellemouton, remember to re-request review from reviewers for your latest update |
!lightninglabs-deploy mute |
closing for now - anyone else is welcome to take this over |
This PR addresses this comment suggestion to add a
--proxy
option to proxy http requests for price data over Tor.It seems to me from testing that I have done than CoinCap does not allow requests over tor, but CoinDesk does. So in this PR the default backend is CoinCap if no proxy is set and is CoinDesk if a proxy is set. If both proxy and backend are specified then a validation check is done to check if the specified backend supports proxy requests.