|
5 | 5 |
|
6 | 6 | import java.io.IOException; |
7 | 7 | import java.io.OutputStream; |
| 8 | +import java.net.Proxy; |
| 9 | +import java.net.ProxySelector; |
8 | 10 | import java.net.Socket; |
| 11 | +import java.net.URI; |
| 12 | +import java.net.URISyntaxException; |
9 | 13 | import java.util.Arrays; |
| 14 | +import java.util.List; |
10 | 15 | import java.util.Locale; |
11 | 16 | import java.util.concurrent.Callable; |
12 | 17 | import java.util.concurrent.ExecutionException; |
@@ -61,13 +66,23 @@ boolean ping(int maxAttempts, int startTimeout) { |
61 | 66 | attempts++; |
62 | 67 | timeout *= 2; |
63 | 68 | } |
64 | | - String error = String.format("Error pinging server (attempts: %d, max timeout: %d). " + |
65 | | - "If you see this message, please, email me danikula@gmail.com " + |
66 | | - "or create issue here https://github.com/danikula/AndroidVideoCache/issues", attempts, timeout / 2); |
| 69 | + String error = String.format(Locale.US, "Error pinging server (attempts: %d, max timeout: %d). " + |
| 70 | + "If you see this message, please, report at https://github.com/danikula/AndroidVideoCache/issues/134. " + |
| 71 | + "Default proxies are: %s" |
| 72 | + , attempts, timeout / 2, getDefaultProxies()); |
67 | 73 | LOG.error(error, new ProxyCacheException(error)); |
68 | 74 | return false; |
69 | 75 | } |
70 | 76 |
|
| 77 | + private List<Proxy> getDefaultProxies() { |
| 78 | + ProxySelector proxySelector = ProxySelector.getDefault(); |
| 79 | + try { |
| 80 | + return proxySelector.select(new URI("https://github.com")); |
| 81 | + } catch (URISyntaxException e) { |
| 82 | + throw new IllegalStateException(e); |
| 83 | + } |
| 84 | + } |
| 85 | + |
71 | 86 | boolean isPingRequest(String request) { |
72 | 87 | return PING_REQUEST.equals(request); |
73 | 88 | } |
|
0 commit comments