-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (48 loc) · 1.98 KB
/
app.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
54
55
56
57
58
// Imports
const geoip = require('geoip-lite');
const express = require('express');
const ngrok = require('ngrok');
const path = require('path');
const app = express()
const port = 8080
// Your ngrok auth token (Get it here: https://dashboard.ngrok.com/get-started/your-authtoken)
const token = 'PUT YOUR AUTH TOKEN HERE'
// Terminal Color Variables
const Reset = '\x1b[0m'
const Bold = '\x1b[1m'
const Dim = '\x1b[2m'
const Underline = '\x1b[4m'
const Green = '\x1b[32m'
const Yellow = '\x1b[33m'
// Main Server Function
function startServer() {
// Creating Ngrok Tunnel
(async function() {
const url = await ngrok.connect({authtoken: token, addr: 8080})
console.log(Yellow + 'Your url: ' + Reset, url)
})();
// App Request Handler
app.get('/', (req, res) => {
// Declare User Request Variables
var userAgent = req.get('User-Agent')
var ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
if (ip.substr(0, 7) == '::ffff:') {
ip = ip.substr(7)
}
var geo = geoip.lookup(ip);
// Server Side Responses (Admin Feedback)
console.log(Bold + Green + '\nNew Request Received ✓\n' + Reset)
console.log(Yellow + 'IP: ' + Reset, Underline + ip + Reset)
console.log(Yellow + 'User-Agent: ' + Reset, userAgent)
console.log(Yellow + 'Geo: ' + Reset, JSON.stringify(geo, null, 2) + '\n')
//Client Side Responses (Client View)
res.sendFile(path.join(__dirname, 'public/index.html'))
})
// App Listener
app.listen(port, () => {
console.log(Yellow + ' _____ _ _ \n| ___(_)___| |__ ___ _ __ _ __ ___ __ _ _ __ \n| |_ | / __| \'_ \\ / _ \\ \'__| \'_ \` _ \\ / _` | \'_ \\ \n| _| | \\__ \\ | | | __/ | | | | | | | (_| | | | |\n|_| |_|___/_| |_|\\___|_| |_| |_| |_|\\__,_|_| |_|')
console.log(Dim + 'By Dox-Dev (https://github.com/dox-dev)\n' + Reset)
})
}
// Start Server
startServer()