From 236859949714c5e2382caf265385dc06ec7dcb3d Mon Sep 17 00:00:00 2001 From: Mango <144482551+outment@users.noreply.github.com> Date: Sun, 23 Feb 2025 20:25:44 -0800 Subject: [PATCH] Added error page. --- 503.html | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app.js | 9 +++++++ 2 files changed, 83 insertions(+) create mode 100644 503.html diff --git a/503.html b/503.html new file mode 100644 index 0000000..08bfb2b --- /dev/null +++ b/503.html @@ -0,0 +1,74 @@ + + + + + + + Proxy Route Failure + + + + +
+
+

Proxy Route Failure

+

GET [REDACTED]

+

PFPRXY failed to connect to Project Furina Servers.

+ +

Further Information

+
+
Project Furina Proxy attempted to connect to the target machine, but the target machine did not respond in a timely matter.
+
ERROR: PFPRXY_CONNECTION_TIMEOUT
+
+ PFPRXY encountered a connection error, therefore you are not able to access this website at the moment. +
+
+ + + \ No newline at end of file diff --git a/app.js b/app.js index 9579181..0841d69 100644 --- a/app.js +++ b/app.js @@ -1,8 +1,10 @@ const net = require('net') const http = require('http') +const fs = require('fs') const httpProxy = require('http-proxy') const PORT = process.env.PORT || 3000 +const errorPage = fs.readFileSync('503.html', 'utf8') function createProxyAgent(req) { return new http.Agent({ @@ -17,6 +19,13 @@ function createProxyAgent(req) { const proxy = httpProxy.createProxyServer({}) +proxy.on('error', (err, req, res) => { + if (res) { + if (!res.headersSent) res.writeHead(503, { 'Content-Type': 'text/html' }) + res.end(errorPage) + } +}) + const server = http.createServer((req, res) => { const targetUrl = 'http://147.185.221.25:33187' const agent = createProxyAgent(req)