This commit is contained in:
Manfred Karrer 2018-01-20 19:24:18 -05:00
parent ada683805b
commit 8360f3b0e3
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
3 changed files with 7 additions and 19 deletions

View file

@ -90,7 +90,6 @@ public class ProvidersRepository {
else
log.warn("We received banned provider nodes: bannedNodes={}, selected baseUrl={}, providerList={}",
bannedNodes, baseUrl, providerList);
}
public void selectNewRandomBaseUrl() {

View file

@ -405,17 +405,8 @@ public class MainViewModel implements ViewModel {
initWalletService();
// We want to get early connected to the price relay so we call it already now
long ts = new Date().getTime();
final boolean[] logged = {false};
priceFeedService.setCurrencyCodeOnInit();
priceFeedService.requestPriceFeed(price -> {
if (!logged[0]) {
log.info("We received data from the price relay after {} ms.",
(new Date().getTime() - ts));
logged[0] = true;
}
},
(errorMessage, throwable) -> log.error("requestPriceFeed failed:" + errorMessage));
priceFeedService.initialRequestPriceFeed();
}
@Override

View file

@ -4,6 +4,7 @@ import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
import io.bisq.common.app.Version;
import io.bisq.network.Socks5ProxyProvider;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
@ -14,8 +15,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.inject.Inject;
@ -31,9 +30,8 @@ import java.util.UUID;
import static com.google.common.base.Preconditions.checkNotNull;
// TODO close connection if failing
@Slf4j
public class HttpClient {
private static final Logger log = LoggerFactory.getLogger(HttpClient.class);
@Nullable
private Socks5ProxyProvider socks5ProxyProvider;
@Getter
@ -142,19 +140,19 @@ public class HttpClient {
new PoolingHttpClientConnectionManager(reg) :
new PoolingHttpClientConnectionManager(reg, new FakeDnsResolver());
try (CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build()) {
InetSocketAddress socksaddr = new InetSocketAddress(socks5Proxy.getInetAddress(), socks5Proxy.getPort());
InetSocketAddress socksAddress = new InetSocketAddress(socks5Proxy.getInetAddress(), socks5Proxy.getPort());
// remove me: Use this to test with system-wide Tor proxy, or change port for another proxy.
// InetSocketAddress socksaddr = new InetSocketAddress("127.0.0.1", 9050);
// InetSocketAddress socksAddress = new InetSocketAddress("127.0.0.1", 9050);
HttpClientContext context = HttpClientContext.create();
context.setAttribute("socks.address", socksaddr);
context.setAttribute("socks.address", socksAddress);
HttpGet request = new HttpGet(baseUrl + param);
if (headerKey != null && headerValue != null)
request.setHeader(headerKey, headerValue);
log.debug("Executing request " + request + " proxy: " + socksaddr);
log.debug("Executing request " + request + " proxy: " + socksAddress);
try (CloseableHttpResponse response = httpclient.execute(request, context)) {
return convertInputStreamToString(response.getEntity().getContent());
}