mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2025-01-06 01:20:28 +05:30
Add support for an external proxy.
This commit is contained in:
parent
41395b47d0
commit
f18f87c736
@ -2,3 +2,6 @@
|
|||||||
# The port to Listen on.
|
# The port to Listen on.
|
||||||
PORT: 8080
|
PORT: 8080
|
||||||
|
|
||||||
|
# Proxy
|
||||||
|
PROXY_PART: https://pipedproxy.kavin.rocks
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ public class Constants {
|
|||||||
|
|
||||||
public static final int PORT;
|
public static final int PORT;
|
||||||
|
|
||||||
|
public static final String PROXY_PART;
|
||||||
|
|
||||||
public static final StreamingService YOUTUBE_SERVICE;
|
public static final StreamingService YOUTUBE_SERVICE;
|
||||||
|
|
||||||
public static final HttpClient h2client = HttpClient.newBuilder().followRedirects(Redirect.NORMAL)
|
public static final HttpClient h2client = HttpClient.newBuilder().followRedirects(Redirect.NORMAL)
|
||||||
@ -34,6 +36,7 @@ public class Constants {
|
|||||||
prop.load(new FileReader("config.properties"));
|
prop.load(new FileReader("config.properties"));
|
||||||
|
|
||||||
PORT = Integer.parseInt(prop.getProperty("PORT"));
|
PORT = Integer.parseInt(prop.getProperty("PORT"));
|
||||||
|
PROXY_PART = prop.getProperty("PROXY_PART");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,8 @@ public class ResponseHelper {
|
|||||||
if (!hasQuery && path.startsWith("/vi/"))
|
if (!hasQuery && path.startsWith("/vi/"))
|
||||||
path = path.replace("/vi/", "/vi_webp/").replace(".jpg", ".webp");
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user