This repository has been archived by the owner on Aug 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added public key creation, restyled img page to match uploader, added…
… logging bc anyone can make a key now lol
- Loading branch information
big cock
committed
Aug 20, 2023
1 parent
7f3f524
commit 1bf0618
Showing
9 changed files
with
154 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
uploads | ||
node_modules | ||
keys.json | ||
upload-log.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
"use strict"; | ||
|
||
interface Config { | ||
port: number; | ||
dirs: string[]; | ||
keys: string[]; | ||
} | ||
|
||
const config: Config = { | ||
port: 8080, | ||
dirs: ["suicidey", "pp", "kms", "fbi", "cia", "666", "777"], | ||
keys: ["fuckurmom"], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Router, Request, Response } from "express"; | ||
import fs from "fs"; | ||
|
||
const router = Router(); | ||
|
||
router.post("/", (req: Request, res: Response) => { | ||
try { | ||
const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress; | ||
const keys = JSON.parse(fs.readFileSync("keys.json", "utf8")); | ||
|
||
const newKey = { | ||
key: generateRandomKey(10), | ||
created_at: new Date().toISOString(), | ||
ip: ip, | ||
}; | ||
|
||
keys.push(newKey); | ||
|
||
fs.writeFileSync("keys.json", JSON.stringify(keys, null, 2)); | ||
|
||
res.send({ | ||
status: 200, | ||
message: "Key created successfully.", | ||
key: newKey.key, | ||
}); | ||
} catch (err) { | ||
console.error(`Failed to create key: ${err}`); | ||
res.status(500).send({ | ||
status: 500, | ||
message: "Failed to create key.", | ||
error: err, | ||
}); | ||
} | ||
}); | ||
|
||
function generateRandomKey(length: number): string { | ||
const chars = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
let result = ""; | ||
|
||
for (let i = 0; i < length; i++) { | ||
result += chars.charAt(Math.floor(Math.random() * chars.length)); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |