forked from github-mirror/Verome-API
добавил прокси и докер
This commit is contained in:
29
mod.ts
29
mod.ts
@@ -9,6 +9,10 @@
|
||||
import { serve } from "https://deno.land/std@0.208.0/http/server.ts";
|
||||
import { YTMusic, YouTubeSearch, LastFM, fetchFromPiped, fetchFromInvidious, getLyrics, getTrendingMusic, getRadio, getTopArtists, getTopTracks, getArtistInfo, getTrackInfo, getSongComplete, getAlbumComplete, getArtistComplete, getFullChain } from "./lib.ts";
|
||||
import { html as uiHtml } from "./ui.ts";
|
||||
import { installProxyFetch } from "./proxy.ts";
|
||||
|
||||
// ── Proxy must be installed BEFORE any fetch calls ──────────────────────────
|
||||
installProxyFetch();
|
||||
|
||||
const PORT = parseInt(Deno.env.get("PORT") || "8000");
|
||||
|
||||
@@ -94,6 +98,31 @@ async function handler(req: Request): Promise<Response> {
|
||||
if (pathname === "/favicon.ico") return new Response(null, { status: 204 });
|
||||
if (pathname === "/health") return json({ status: "ok" });
|
||||
|
||||
// ============ PROXY CONFIG ============
|
||||
|
||||
if (pathname === "/api/proxy/config") {
|
||||
const httpsProxy = Deno.env.get("HTTPS_PROXY") || Deno.env.get("https_proxy");
|
||||
const httpProxy = Deno.env.get("HTTP_PROXY") || Deno.env.get("http_proxy");
|
||||
const proxyUrl = Deno.env.get("PROXY_URL");
|
||||
const noProxy = Deno.env.get("NO_PROXY") || Deno.env.get("no_proxy");
|
||||
const active = !!(httpsProxy || httpProxy || proxyUrl);
|
||||
|
||||
// Mask credentials in proxy URL for display
|
||||
const mask = (u: string | undefined) =>
|
||||
u ? u.replace(/:\/\/[^@]*@/, "://<hidden>@") : null;
|
||||
|
||||
return json({
|
||||
proxy_enabled: active,
|
||||
https_proxy: mask(httpsProxy || undefined),
|
||||
http_proxy: mask(httpProxy || undefined),
|
||||
proxy_url: mask(proxyUrl || undefined),
|
||||
no_proxy: noProxy || null,
|
||||
note: active
|
||||
? "All outbound requests are routed through the proxy"
|
||||
: "No proxy configured — direct connections are used",
|
||||
});
|
||||
}
|
||||
|
||||
// ============ SEARCH ============
|
||||
|
||||
if (pathname === "/api/search") {
|
||||
|
||||
Reference in New Issue
Block a user