summaryrefslogtreecommitdiff
path: root/src/ws
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-15 08:10:26 -0700
committer8cy <[email protected]>2020-04-15 08:10:26 -0700
commit972c2ef86a59f0d90da9c11bcdfc9d7245379186 (patch)
tree69ef94319bae5f44f3438f409cea9a467d53d296 /src/ws
parenton msg also log server name, v5.0.6 (diff)
downloaddep-core-972c2ef86a59f0d90da9c11bcdfc9d7245379186.tar.xz
dep-core-972c2ef86a59f0d90da9c11bcdfc9d7245379186.zip
The Uwulapse, v6.0.0
- add webserver - fix servercount - formatting
Diffstat (limited to 'src/ws')
-rw-r--r--src/ws/layouts/layout.hbs18
-rw-r--r--src/ws/public/css/main.css116
-rw-r--r--src/ws/views/error.hbs1
-rw-r--r--src/ws/views/index.hbs1
-rw-r--r--src/ws/ws.ts54
5 files changed, 190 insertions, 0 deletions
diff --git a/src/ws/layouts/layout.hbs b/src/ws/layouts/layout.hbs
new file mode 100644
index 0000000..3cc34cd
--- /dev/null
+++ b/src/ws/layouts/layout.hbs
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>{{title}}</title>
+ <link rel="stylesheet" href="css/main.css">
+ </head>
+ <body>
+ <div title="Status">
+ {{body}}
+ </div>
+
+ <div class="footer">
+ <p>Copyright &COPY; 2020 - <a href="https://cyne.cf">s1nical</a></p>
+ </div>
+ </body>
+</html> \ No newline at end of file
diff --git a/src/ws/public/css/main.css b/src/ws/public/css/main.css
new file mode 100644
index 0000000..993c46a
--- /dev/null
+++ b/src/ws/public/css/main.css
@@ -0,0 +1,116 @@
+@import url('https://fonts.googleapis.com/css?family=Fira+Mono:400');
+
+body {
+ display: flex;
+ width: 100vw;
+ height: 100vh;
+ align-items: center;
+ justify-content: center;
+ margin: 0;
+ background: #131313;
+ color: #fff;
+ font-size: 96px;
+ font-family: 'Fira Mono', monospace;
+ letter-spacing: -7px;
+}
+
+div {
+ animation: glitch 1s linear infinite;
+}
+
+@keyframes glitch {
+
+ 2%,
+ 64% {
+ transform: translate(2px, 0) skew(0deg);
+ }
+
+ 4%,
+ 60% {
+ transform: translate(-2px, 0) skew(0deg);
+ }
+
+ 62% {
+ transform: translate(0, 0) skew(5deg);
+ }
+}
+
+div:before,
+div:after {
+ content: attr(title);
+ position: absolute;
+ left: 0;
+}
+
+div:before {
+ animation: glitchTop 1s linear infinite;
+ clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
+ -webkit-clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
+}
+
+@keyframes glitchTop {
+
+ 2%,
+ 64% {
+ transform: translate(2px, -2px);
+ }
+
+ 4%,
+ 60% {
+ transform: translate(-2px, 2px);
+ }
+
+ 62% {
+ transform: translate(13px, -1px) skew(-13deg);
+ }
+}
+
+div:after {
+ animation: glitchBotom 1.5s linear infinite;
+ clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
+ -webkit-clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
+}
+
+@keyframes glitchBotom {
+
+ 2%,
+ 64% {
+ transform: translate(-2px, 0);
+ }
+
+ 4%,
+ 60% {
+ transform: translate(-2px, 0);
+ }
+
+ 62% {
+ transform: translate(-22px, 5px) skew(21deg);
+ }
+}
+
+#green {
+ color: #05ffa1
+}
+
+a {
+ color: white;
+ text-decoration: none;
+ transition: 0.5s;
+}
+
+a:hover {
+ color: rgb(223, 222, 222);
+ text-decoration: none;
+ transition: 0.5s;
+}
+
+.footer {
+ position: fixed;
+ left: 0;
+ bottom: 0;
+ width: 100%;
+ color: white;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: -1px;
+} \ No newline at end of file
diff --git a/src/ws/views/error.hbs b/src/ws/views/error.hbs
new file mode 100644
index 0000000..fe49573
--- /dev/null
+++ b/src/ws/views/error.hbs
@@ -0,0 +1 @@
+Error: {{errtype}} \ No newline at end of file
diff --git a/src/ws/views/index.hbs b/src/ws/views/index.hbs
new file mode 100644
index 0000000..5253033
--- /dev/null
+++ b/src/ws/views/index.hbs
@@ -0,0 +1 @@
+Status: Online \ No newline at end of file
diff --git a/src/ws/ws.ts b/src/ws/ws.ts
new file mode 100644
index 0000000..08f9581
--- /dev/null
+++ b/src/ws/ws.ts
@@ -0,0 +1,54 @@
+import express from 'express';
+import hbs from 'express-handlebars';
+import bodyParser from 'body-parser';
+import path from 'path';
+
+class WebSocket {
+ constructor(token, port, client) {
+ this.token = token;
+ this.client = client;
+
+ this.app = express()
+ this.app.engine('hbs', hbs({
+ extname: 'hbs',
+ defaultLayout: 'layout',
+ layoutsDir: __dirname + '/layouts'
+ }))
+ this.app.set('views', path.join(__dirname, 'views'))
+ this.app.set('view engine', 'hbs')
+ this.app.use(express.static(path.join(__dirname, 'public')))
+ this.app.use(bodyParser.urlencoded({ extended: false }))
+ this.app.use(bodyParser.json())
+
+ this.registerRoots()
+
+ this.server = this.app.listen(port, () => {
+ console.log(`Websocket listening on port ${this.server.address().port}`)
+ })
+ }
+
+ checkToken(_token) {
+ return (_token == this.token)
+ }
+
+ // http://localhost:port?token=123456
+ registerRoots() {
+ this.app.get('/', (req, res) => {
+ var _token = req.query.token
+ // if (!this.checkToken(_token)) {
+ // res.render('error', {
+ // title: 's1nical - Error',
+ // errtype: 'INVALID TOKEN'
+ // })
+ // return
+ // }
+
+ res.render('index', {
+ title: 'Uwufier - Status',
+ token: _token
+ })
+ })
+ }
+}
+
+module.exports = WebSocket \ No newline at end of file