-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
53 lines (46 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
process.on("unhandledRejection", (reason, promise) => {
console.log("--- An error occurred, please report this to lapisfloof on Discord ---")
console.error(reason)
console.log("--- An error occurred, please report this to lapisfloof on Discord ---")
})
process.on("uncaughtException", (error, origin) => {
if (error.code !== "CUSTOM_NOLOG") {
console.log("--- An exception occurred, please report this to lapisfloof on Discord ---")
console.error(error)
console.log("--- An exception occurred, please report this to lapisfloof on Discord ---")
}
try {
rl.close()
proxy.destroy()
} catch (error) {
}
//keep process alive so the window doesn't close if this is being ran in the .exe
setInterval(() => {}, 9999999)
})
import "./hideWarning.js"
import { Proxy } from "./Proxy.js"
import { handleCommand } from "./commands/handler.js"
import readline from "readline"
if (process.stopExecution) {
//something in the imports had an error, so don't start the proxy
let errorThrowing = new Error()
errorThrowing.code = "CUSTOM_NOLOG"
throw errorThrowing
}
console.log("Starting proxy...")
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
rl.on("line", handleLine)
rl.on("SIGINT", handleSigint)
function handleLine(line) {
let isCommand = handleCommand(null, line, null, "console", proxy)
if (!isCommand) console.log("Unknown command. Do \"help\" for a list of commands.")
}
async function handleSigint() {
//do nothing because people type ctrl+c to copy text too
//rl.close()
//process.exit()
}
const proxy = new Proxy()