Browse Source

add logging to telegram

main
Trinity POINTARD 11 months ago
parent
commit
b0427a8c19
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 16
      worker/worker.js

2
Cargo.lock

@ -428,7 +428,7 @@ dependencies = [
]
[[package]]
name = "tango-charlier"
name = "tango-charlie"
version = "0.1.0"
dependencies = [
"base64-url",

2
Cargo.toml

@ -1,5 +1,5 @@
[package]
name = "tango-charlier"
name = "tango-charlie"
version = "0.1.0"
authors = ["Trinity POINTARD <pierretrinity.pointard@alten.com>"]
edition = "2018"

16
worker/worker.js

@ -4,6 +4,8 @@ addEventListener('fetch', (event) => {
//const SERVER_SECRET = env
//const TELEGRAM = env
/** * Fetch and log a request * @param {Request} request */
async function handleRequest(request) {
try {
@ -17,10 +19,24 @@ async function handleRequest(request) {
output = adv(ip, SERVER_SECRET);
output = JSON.stringify(output);
} else if (RegExp("^/rec/[^?]*").test(uri) && request.method === "POST") {
const payload = {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
chat_id: "798481752",
text: `Received a decrypt request from ${ip}`,
}),
};
const res = fetch(TELEGRAM, payload);
const { rec } = wasm_bindgen
const body = await request.json();
output = rec(ip, body, SERVER_SECRET);
output = JSON.stringify(output);
await res;
}
let res = new Response(output, { status: 200 });

Loading…
Cancel
Save