diff --git a/.gitignore b/.gitignore index e33f815..569f1ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -# public directory -public/ \ No newline at end of file +node_modules/ +package-lock.json +docker-compose.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1697dbe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:18 +WORKDIR /usr/src/app +COPY package*.json ./ +RUN npm install --only=production +COPY . . +EXPOSE 3000 +CMD ["node", "app.js"] \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..8f5559e --- /dev/null +++ b/app.js @@ -0,0 +1,62 @@ +const express = require('express'); +const bodyParser = require('body-parser'); +const path = require('path'); +const winston = require('winston'); +const rateLimit = require('express-rate-limit'); + +const logger = winston.createLogger({ + level: 'info', + format: winston.format.combine( + winston.format.timestamp(), + winston.format.printf(({ timestamp, level, message }) => { + return `${timestamp} [${level.toUpperCase()}] ${message}`; + }) + ), + transports: [ + new winston.transports.File({ filename: 'register.log' }) + ], +}); + +const registerLimiter = rateLimit({ + windowMs: 24 * 60 * 60 * 1000, + max: 1, + message: 'You have already submitted a registration today. Please try again tomorrow.', + standardHeaders: true, + legacyHeaders: false, +}); + +const app = express(); + +app.set('view engine', 'ejs'); +app.set('views', path.join(__dirname, 'src')); + +app.use(bodyParser.urlencoded({ extended: false })); + +app.use(express.static(path.join(__dirname, 'public'))); + +app.get('/', (req, res) => { + res.render('index'); +}); + +app.post('/register', registerLimiter, (req, res) => { + const formData = req.body; + logger.info(`New registration: + Name: ${formData.name} + Email: ${formData.email} + Reason: ${formData.message} + Telegram: ${formData.telegram}`); + res.render('success'); +}); + +app.get('/register', (req, res) => { + res.render('register'); +}); + +app.get('/services', (req, res) => { + res.render('services'); +}); + +const PORT = process.env.PORT || 3000; +app.listen(PORT, () => { + console.log(`Server is running on port ${PORT}`); +}); \ No newline at end of file diff --git a/default.conf b/default.conf deleted file mode 100644 index 5a65bb3..0000000 --- a/default.conf +++ /dev/null @@ -1,5 +0,0 @@ -server { - location / { - root /data/www; - } -} \ No newline at end of file diff --git a/docker-compose.yml.example b/docker-compose.yml.example index 79d4926..1f431ac 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -1,9 +1,11 @@ services: - mail: - image: nginx - restart: always - ports: - - 2380:80 - volumes: - - /path/to/root/default.conf:/etc/nginx/conf.d/default.conf - - /path/to/root/public:/data/www/ \ No newline at end of file + pontus-mail: + build: . + container_name: pontus-mail + restart: always + ports: + - "80:3000" + volumes: + - ./register.log:/usr/src/app/register.log + environment: + - NODE_ENV=production \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ae9a043 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "pontus-mail", + "version": "1.0.0", + "description": "Landing page for p0ntus mail", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "body-parser": "^1.20.3", + "ejs": "^3.1.10", + "express": "^4.21.1", + "express-rate-limit": "^7.4.1", + "winston": "^3.17.0" + } +} diff --git a/src/css/main.css b/public/css/main.css similarity index 100% rename from src/css/main.css rename to public/css/main.css diff --git a/public/js/checkUsernameInput.js b/public/js/checkUsernameInput.js new file mode 100644 index 0000000..b9fd612 --- /dev/null +++ b/public/js/checkUsernameInput.js @@ -0,0 +1,9 @@ +document.getElementById('email').addEventListener('input', function() { + let emailInput = document.getElementById('email').value; + let prefix = document.getElementById('email-prefix'); + if (emailInput.includes('@p0ntus.com')) { + prefix.innerText = emailInput.split('@')[0]; + } else { + prefix.innerText = emailInput; + } +}); \ No newline at end of file diff --git a/register.log b/register.log new file mode 100644 index 0000000..d6c7a60 --- /dev/null +++ b/register.log @@ -0,0 +1,6 @@ +{"formData":{"email":"iurfhiu","message":"fwiuhef","name":"uifrhifh","telegram":"fiuwhwiu"},"level":"info","message":"New registration","timestamp":"2024-12-03T23:20:47.428Z"} +2024-12-03T23:23:44.763Z [INFO] New registration: + Name: refefrfre + Email: frferefr + Message: ffferfrefe + Telegram: erffreefr diff --git a/self b/self deleted file mode 100755 index 390bc08..0000000 --- a/self +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -SC_VERSION=1.0.0 -SC_CODENAME="wormhole" -COLOR_RESET="\033[0m" -COLOR_GREEN="\033[1;32m" -COLOR_RED="\033[1;31m" -COLOR_YELLOW="\033[1;33m" -COLOR_BLUE="\033[1;34m" -COLOR_CYAN="\033[1;36m" - -function start() { - if [ ! -d "src" ]; then - echo -e "${COLOR_RED}src directory not found, cannot continue${COLOR_RESET}" - exit 1 - fi - - mkdir -p public - - cp -r src/* public/ - echo -e "${COLOR_GREEN}Created public dir and copied files successfully${COLOR_RESET}" -} - -function stop() { - if [ -d "public" ]; then - rm -rf public - echo -e "${COLOR_GREEN}Deleted public directory${COLOR_RESET}" - else - echo -e "${COLOR_RED}No public directory to delete${COLOR_RESET}" - fi -} - -function help() { - echo -e "${COLOR_GREEN}self version:${COLOR_RESET} ${COLOR_BLUE}${SC_VERSION} ${SC_CODENAME}${COLOR_RESET}" - echo -e "${COLOR_BLUE}Usage:${COLOR_RESET} ./self [command]\n" - echo -e "${COLOR_YELLOW}Commands:${COLOR_RESET}" - echo -e " ${COLOR_CYAN}help${COLOR_RESET} Shows this help message." - echo -e " ${COLOR_CYAN}start${COLOR_RESET} Copies files to public directory." - echo -e " ${COLOR_CYAN}stop${COLOR_RESET} Removes public directory." -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - help) - help - ;; - *) - echo -e "${COLOR_RED}Invalid command: $1\n${COLOR_RESET}" - help - exit 1 - ;; -esac \ No newline at end of file diff --git a/src/index.html b/src/index.ejs similarity index 86% rename from src/index.html rename to src/index.ejs index f471a86..8418a0e 100644 --- a/src/index.html +++ b/src/index.ejs @@ -15,16 +15,15 @@

p0ntus mail.

simple, mindful, secure email.

- Where can I direct your request?

If you aren't a current user

- Register + Register

If you are a current user

Webmail diff --git a/src/register.ejs b/src/register.ejs new file mode 100644 index 0000000..71480ce --- /dev/null +++ b/src/register.ejs @@ -0,0 +1,43 @@ + + + + + + Register - p0ntus mail + + + + + + + +
+

Register

+

Registration is done via email

+ Fill out the form and send your email to receive your credentials. +
+
+
+ + +
+
+ + +
Your email will be: name@p0ntus.com
+
+
+ + +
+
+ + +
+ +
+
+ + + + \ No newline at end of file diff --git a/src/register.html b/src/register.html deleted file mode 100644 index d1f273a..0000000 --- a/src/register.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - Register - p0ntus mail - - - - - - - -
-

Register

-

Registration is done on Telegram

- Click the button below to register -
- -
- - - \ No newline at end of file diff --git a/src/services.html b/src/services.ejs similarity index 100% rename from src/services.html rename to src/services.ejs