Skip to content

Commit

Permalink
Used client address for terminal emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobleiler committed Oct 30, 2023
1 parent d0700a2 commit dc3acb6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/routes/[[birb]]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export function GET(event: RequestEvent) {
console.log("ClientAddress", event.getClientAddress());
const encoder = new TextEncoder();
const readable = new ReadableStream({
async start(controller) {
async start(controller) {
const client: string = event.getClientAddress();
const path: string = (event.url.pathname == "/") ? "" : event.url.pathname;
let birb: string = event.params.birb ? event.params.birb : "";
birb = validateBirb(birb);
Expand All @@ -90,10 +91,10 @@ export function GET(event: RequestEvent) {
let color: string = getRandomColor();
let birbIndex: number = 0;
const options = getOptions(event.url.searchParams);

controller.enqueue(encoder.encode(clearTerminal));
await delay(5);
controller.enqueue(encoder.encode(`[root@localhost ~] $ `));
controller.enqueue(encoder.encode(`[root@${client} ~] $ `));
await delay(1000);
for (const letter of introText) {
controller.enqueue(encoder.encode(colors["white"](letter)));
Expand Down

0 comments on commit dc3acb6

Please sign in to comment.