GUI-STUDIO commited on
Commit
2bb5f70
·
1 Parent(s): a78eb42

feat: Add DnsResolverRouter

Browse files

Integrates the DnsResolverRouter into the backend and Cloudflare worker
applications.
This change introduces a new routing mechanism for DNS resolution
requests.
The 'test.ts' file in the app-ffmpeg package has been updated to use the
'ky'
library for making requests to the new DNS resolver endpoint. This
replaces
the direct use of 'node:dns/promises'.

Files changed (2) hide show
  1. package.json +1 -0
  2. src/sub-router/test.ts +47 -15
package.json CHANGED
@@ -24,6 +24,7 @@
24
  "ffprobe-static": "^3.1.0",
25
  "fluent-ffmpeg": "^2.1.3",
26
  "http-errors": "^2.0.1",
 
27
  "random-word-slugs": "^0.1.7",
28
  "txtgen": "^3.0.7"
29
  },
 
24
  "ffprobe-static": "^3.1.0",
25
  "fluent-ffmpeg": "^2.1.3",
26
  "http-errors": "^2.0.1",
27
+ "ky": "^1.14.3",
28
  "random-word-slugs": "^0.1.7",
29
  "txtgen": "^3.0.7"
30
  },
src/sub-router/test.ts CHANGED
@@ -1,6 +1,11 @@
1
  import { Context, Elysia, t } from "elysia";
2
- import { lookup } from "node:dns/promises";
3
  import https from "node:https";
 
 
 
 
 
 
4
 
5
  const sub_router = new Elysia({ prefix: "/test" }).get("/foo", async (ctx) => {
6
  const { query, params, request, status } = ctx;
@@ -8,28 +13,55 @@ const sub_router = new Elysia({ prefix: "/test" }).get("/foo", async (ctx) => {
8
  const REQ0 = request.url;
9
  const REQ_ORIGIN = (ctx as any).publicOrigin || new URL(REQ0).origin;
10
 
 
 
 
 
 
 
 
11
  let target = new URL(
12
  "https://dl.gemlelispe.workers.dev/https%3A%2F%2Fbcdnxw.hakunaymatata.com%2Fbt%2F7e1c2ff4f2a619c16f40825883eebe6e.mp4%3Fsign%3D288c2a2346ad3cd3c22dcc70e483ca7f%26t%3D1773678165?n=Vini%20Jr.%20(2025)"
13
  );
14
 
15
- const res = await fetch(target.href, {
16
- headers: {
17
- host: "dl.gemlelispe.workers.dev",
18
- origin: "dl.gemlelispe.workers.dev",
19
- referer: "https://dl.vidsrc.vip/"
20
- },
21
- referrerPolicy: "no-referrer"
 
22
  });
23
 
24
- const res_status = res.status;
25
- const res_headers = res.headers;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- const res_headers_object = Object.fromEntries((res_headers as any).entries());
28
 
29
- return {
30
- res_status,
31
- res_headers: res_headers_object
32
- };
33
  });
34
 
35
  export const TestRouter = sub_router;
 
1
  import { Context, Elysia, t } from "elysia";
 
2
  import https from "node:https";
3
+ import { NS_error } from "../../../../../packages/lib/helpers/client/error";
4
+ import { NS_routes_c } from "../../../../../packages/lib/helpers/client/route";
5
+ import { NS_promise } from "../../../../../packages/lib/helpers/client/promise";
6
+ import ky from "ky";
7
+
8
+ const REPO_ORIGIN = process.env.REPO_ORIGIN;
9
 
10
  const sub_router = new Elysia({ prefix: "/test" }).get("/foo", async (ctx) => {
11
  const { query, params, request, status } = ctx;
 
13
  const REQ0 = request.url;
14
  const REQ_ORIGIN = (ctx as any).publicOrigin || new URL(REQ0).origin;
15
 
16
+ if (!REPO_ORIGIN) {
17
+ throw NS_error.F_create_error({
18
+ status: 400,
19
+ message: "Repo origin undefined"
20
+ });
21
+ }
22
+
23
  let target = new URL(
24
  "https://dl.gemlelispe.workers.dev/https%3A%2F%2Fbcdnxw.hakunaymatata.com%2Fbt%2F7e1c2ff4f2a619c16f40825883eebe6e.mp4%3Fsign%3D288c2a2346ad3cd3c22dcc70e483ca7f%26t%3D1773678165?n=Vini%20Jr.%20(2025)"
25
  );
26
 
27
+ const [E_, R_] = await NS_promise.F_catch_promise({
28
+ promise: ky
29
+ .post(NS_routes_c.F_flat_url_slash(`${REPO_ORIGIN}/dns/lookup`), {
30
+ json: {
31
+ target: target.href
32
+ }
33
+ })
34
+ .json()
35
  });
36
 
37
+ if (E_ || !R_) {
38
+ const { status, message } = NS_error.F_collect_error_status_n_message({
39
+ ERR: E_
40
+ });
41
+
42
+ throw NS_error.F_create_error({ status, message });
43
+ }
44
+
45
+ return R_;
46
+
47
+ // const res = await fetch(target.href, {
48
+ // headers: {
49
+ // host: "dl.gemlelispe.workers.dev",
50
+ // origin: "dl.gemlelispe.workers.dev",
51
+ // referer: "https://dl.vidsrc.vip/"
52
+ // },
53
+ // referrerPolicy: "no-referrer"
54
+ // });
55
+
56
+ // const res_status = res.status;
57
+ // const res_headers = res.headers;
58
 
59
+ // const res_headers_object = Object.fromEntries((res_headers as any).entries());
60
 
61
+ // return {
62
+ // res_status,
63
+ // res_headers: res_headers_object
64
+ // };
65
  });
66
 
67
  export const TestRouter = sub_router;