Feat : Kiro MITM
This commit is contained in:
1 parent
065761268c
commit
03ff35100d
13 files changed
+266
-169
No files matched your search
@@ -0,0 +1,20 @@
|
||||
const { err } = require("../logger");
|
||||
const { fetchRouter, pipeSSE } = require("./base");
|
||||
|
||||
/**
|
||||
* Intercept Kiro request — replace model and forward to router
|
||||
*/
|
||||
async function intercept(req, res, bodyBuffer, mappedModel) {
|
||||
try {
|
||||
const body = JSON.parse(bodyBuffer.toString());
|
||||
body.model = mappedModel;
|
||||
const routerRes = await fetchRouter(body);
|
||||
await pipeSSE(routerRes, res);
|
||||
} catch (error) {
|
||||
err(`[Kiro] ${error.message}`);
|
||||
if (!res.headersSent) res.writeHead(500, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ error: { message: error.message, type: "mitm_error" } }));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { intercept };
|
||||
Reference in new issue
Block a user