From de0957e71c58ae9bb7a5cff78693946613affff4 Mon Sep 17 00:00:00 2001 From: Saahil Date: Mon, 11 Nov 2024 20:14:41 -0500 Subject: [PATCH] fix: chunk nextdns --- .gitignore | 2 ++ .wakaignore | 1 + src/modules/nextdns.ts | 9 +++++++-- wak.toml | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .wakaignore diff --git a/.gitignore b/.gitignore index a2b3efb..adf7a7a 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,5 @@ dist data.json t.ts ctf/unenc +*.bin +*.txt \ No newline at end of file diff --git a/.wakaignore b/.wakaignore new file mode 100644 index 0000000..191381e --- /dev/null +++ b/.wakaignore @@ -0,0 +1 @@ +.git \ No newline at end of file diff --git a/src/modules/nextdns.ts b/src/modules/nextdns.ts index 3d87b48..7ace19d 100644 --- a/src/modules/nextdns.ts +++ b/src/modules/nextdns.ts @@ -20,7 +20,7 @@ export interface Device { id: string; name: string; } - +export const chunks:string[] = [] export function PrivateDNS(app: ModifiedApp, id: string, channel: string) { const client = new EventSource( `https://api.nextdns.io/profiles/${id}/logs/stream`, @@ -34,10 +34,15 @@ export function PrivateDNS(app: ModifiedApp, id: string, channel: string) { //@ts-ignore delete realData.clientIp; // console.log(`${realData.status == 'blocked' ? ':x:' : ":white_check_mark:"} ${realData.encrypted ? ":lock: " : ""} - ${realData.domain} `) + if(chunks.length < 10) { + chunks.push(`${realData.status == "blocked" ? ":x:" : ":white_check_mark:"} ${realData.encrypted ? ":lock: " : ""} - ${realData.domain} `) + } else { app.client.chat.postMessage({ channel, - text: `${realData.status == "blocked" ? ":x:" : ":white_check_mark:"} ${realData.encrypted ? ":lock: " : ""} - ${realData.domain} `, + text: chunks.join("\n"), }); + } + }; // fetch(`https://api.nextdns.io/profiles/${id}/logs/stream`, { // headers: { "X-Api-Key": process.env.NEXTDNS_API_KEY }, diff --git a/wak.toml b/wak.toml index be6fffd..b21609f 100644 --- a/wak.toml +++ b/wak.toml @@ -5,9 +5,10 @@ version = 1 [files] include = ["*"] # files to include in tracking -exclude = ["/node_modules"] # files to exclude in tracking +exclude = ["/node_modules", ".gits"] # files to exclude in tracking exclude_files = [ ".gitignore", + ".wakaignore" ] # files whose contents will be used to exclude other files from tracking exclude_binary_files = true # whether to ignore binary files