Add support for an external proxy.

This commit is contained in:
FireMasterK 2020-11-13 03:10:50 +05:30
parent 41395b47d0
commit f18f87c736
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58
3 changed files with 8 additions and 1 deletions

View file

@ -2,3 +2,6 @@
# The port to Listen on.
PORT: 8080
# Proxy
PROXY_PART: https://pipedproxy.kavin.rocks

View file

@ -19,6 +19,8 @@ public class Constants {
public static final int PORT;
public static final String PROXY_PART;
public static final StreamingService YOUTUBE_SERVICE;
public static final HttpClient h2client = HttpClient.newBuilder().followRedirects(Redirect.NORMAL)
@ -34,6 +36,7 @@ public class Constants {
prop.load(new FileReader("config.properties"));
PORT = Integer.parseInt(prop.getProperty("PORT"));
PROXY_PART = prop.getProperty("PROXY_PART");
} catch (Exception e) {
throw new RuntimeException(e);
}

View file

@ -173,7 +173,8 @@ public class ResponseHelper {
if (!hasQuery && path.startsWith("/vi/"))
path = path.replace("/vi/", "/vi_webp/").replace(".jpg", ".webp");
return path + (hasQuery ? "?" + query + "&host=" : "?host=") + URLUtils.silentEncode(host);
return Constants.PROXY_PART + path + (hasQuery ? "?" + query + "&host=" : "?host=")
+ URLUtils.silentEncode(host);
}
}