Skip to content

Commit 8fcab9c

Browse files
author
CryptosByte
committed
Frontend Support; Verification
1 parent f4703af commit 8fcab9c

File tree

2 files changed

+111
-32
lines changed

2 files changed

+111
-32
lines changed

public/index.html

Lines changed: 111 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,68 @@
77
<title>Remote Titan</title>
88
<link rel="stylesheet" href="./main.css" />
99
<link rel="stylesheet" href="./terminal.css" />
10+
<style>
11+
.external {
12+
background-color: black;
13+
opacity: 0.3;
14+
display: table;
15+
position: absolute;
16+
top: 0;
17+
left: 0;
18+
height: 100%;
19+
width: 100%;
20+
}
21+
.middle {
22+
display: table-cell;
23+
vertical-align: middle;
24+
}
25+
.internal {
26+
opacity: 1;
27+
margin-left: auto;
28+
margin-right: auto;
29+
width: 400px;
30+
}
31+
</style>
1032
<script defer>
11-
const ws = new WebSocket(`ws://${new URL(window.location.href).host}/api/terminal`)
33+
const ws = new WebSocket(
34+
`ws://${new URL(window.location.href).host}/api/terminal`
35+
);
36+
37+
setTimeout(() => {
38+
if (ws.readyState === 1) {
39+
ws.send(
40+
JSON.stringify({
41+
type: "test_payload",
42+
value: "none",
43+
})
44+
);
45+
}
46+
}, 5);
47+
48+
ws.onmessage = function (data) {
49+
data = JSON.parse(data.data);
50+
51+
if (data.value !== undefined)
52+
document.querySelector(
53+
"div.history"
54+
).innerHTML += `<p>${data.value}</p>`;
55+
56+
if (data.type === "validated") {
57+
document.querySelector("div.validate").innerHTML = "";
58+
document.querySelector("div.root").style = "";
59+
}
60+
};
61+
62+
function conn() {
63+
let inp = document.querySelector(".conn");
64+
if (!inp.value) return;
65+
ws.send(
66+
JSON.stringify({
67+
type: "verify",
68+
value: inp.value,
69+
})
70+
);
71+
}
1272

1373
function execute(event) {
1474
const val = event.target.parentElement.children[0].children[4];
@@ -19,46 +79,66 @@
1979
if (val.value.includes("clear"))
2080
event.target.parentElement.parentElement.children[2].children[0].textContent =
2181
"";
22-
else {
2382

24-
}
83+
ws.send(
84+
JSON.stringify({
85+
type: "cmd",
86+
value: val.value,
87+
})
88+
);
2589

2690
val.value = "";
2791
}
2892
</script>
2993
</head>
3094
<body>
31-
<div class="group">
32-
<div class="terminal_entry">
95+
<div class="root" style="filter: blur(1px); pointer-events: none">
96+
<div class="group">
97+
<div class="terminal_entry">
98+
<span>&nbsp;</span>
99+
<p class="user" style="color: #2ca32c">~</p>
100+
<p class="user"><span>&nbsp;</span>$</p>
101+
<span>&nbsp;</span>
102+
<input
103+
placeholder="Enter Terminal Command"
104+
class="entry"
105+
spellcheck="false"
106+
/>
107+
</div>
33108
<span>&nbsp;</span>
34-
<p class="user" style="color: #2ca32c">~</p>
35-
<p class="user"><span>&nbsp;</span>$</p>
36-
<span>&nbsp;</span>
37-
<input
38-
placeholder="Enter Terminal Command"
39-
class="entry"
40-
spellcheck="false"
41-
/>
109+
<button class="execute" onclick="execute(event)">Run</button>
110+
</div>
111+
<br />
112+
<div class="history">
113+
<p class="time"></p>
42114
</div>
43-
<span>&nbsp;</span>
44-
<button class="execute" onclick="execute(event)">Run</button>
115+
<script>
116+
document.querySelector(
117+
"p.time"
118+
).textContent = `[${new Date().getHours()}:${
119+
new Date().getMinutes() > 10
120+
? new Date().getMinutes()
121+
: `0${new Date().getMinutes()}`
122+
}:${
123+
new Date().getSeconds() > 10
124+
? new Date().getSeconds()
125+
: `0${new Date().getSeconds()}`
126+
}] Remote Titan has been launched!`;
127+
</script>
45128
</div>
46-
<br />
47-
<div class="history">
48-
<p class="time"></p>
129+
<div class="validate">
130+
<div class="external">
131+
<div class="middle">
132+
<div class="internal">
133+
<input
134+
class="conn"
135+
placeholder="Enter Connection Code:"
136+
maxlength="6"
137+
/>
138+
<button onclick="conn()">Submit</button>
139+
</div>
140+
</div>
141+
</div>
49142
</div>
50-
<script>
51-
document.querySelector(
52-
"p.time"
53-
).textContent = `[${new Date().getHours()}:${
54-
new Date().getMinutes() > 10
55-
? new Date().getMinutes()
56-
: `0${new Date().getMinutes()}`
57-
}:${
58-
new Date().getSeconds() > 10
59-
? new Date().getSeconds()
60-
: `0${new Date().getSeconds()}`
61-
}] Remote Titan has been launched!`;
62-
</script>
63143
</body>
64144
</html>

src/server/WebsocketServer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import WebSocket from "ws";
22
import url from "url";
3-
import http from "http";
43
import Client from "./Client";
54

65
export default class WebSocketServer {

0 commit comments

Comments
 (0)