Skip to content

Commit

Permalink
fix the issue blueberry was having in donator-info with ipv6 and http
Browse files Browse the repository at this point in the history
  • Loading branch information
leijurv committed Feb 25, 2020
1 parent 08023dc commit d737a80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Even more workarounds for peoples broken network stacks!

## [0.8.4] - 2020-02-24

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ private static GithubRelease[] fetchReleases(String repo) {
try {
return getFromURL("http://impactclient.net/releases.json");
} catch (Throwable th) {
System.out.println("Unable to fetch from epic site");
System.out.println("Unable to fetch from epic site http");
th.printStackTrace();
}
try {
return getFromURL("https://impactclient.net/releases.json");
} catch (Throwable th) {
System.out.println("Unable to fetch from epic site https");
th.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ public static String fetch(String url) {
}

public static byte[] fetchBytes(String url) {
System.out.println("DOWNLOADING " + url);
try {
return IOUtils.toByteArray(new URI(url));
} catch (Throwable th) {
th.printStackTrace();
}
SSLSocketFactory originalSSL = HttpsURLConnection.getDefaultSSLSocketFactory(); // for restoring later
HostnameVerifier originalHost = HttpsURLConnection.getDefaultHostnameVerifier();
System.out.println("DOWNLOADING " + url);
String originalIPv4 = System.getProperty("java.net.preferIPv4Stack");
try {
System.out.println("Trying some hacks to get this to load!");
System.setProperty("java.net.preferIPv4Stack", "true");
try {
return IOUtils.toByteArray(new URI(url));
} catch (Throwable th) {
Expand All @@ -65,6 +73,8 @@ public static byte[] fetchBytes(String url) {
} catch (NoSuchAlgorithmException | KeyManagementException e) {
throw new RuntimeException(e);
} finally {
System.out.println("Undoing hacks!");
System.setProperty("java.net.preferIPv4Stack", originalIPv4);
try {
HttpsURLConnection.setDefaultSSLSocketFactory(originalSSL); // restore to full https verification
HttpsURLConnection.setDefaultHostnameVerifier(originalHost);
Expand Down

0 comments on commit d737a80

Please sign in to comment.