From 73e400f79a121ca103549a272de4d160da9e2bc2 Mon Sep 17 00:00:00 2001 From: HF Date: Thu, 4 Feb 2021 23:56:12 +0100 Subject: [PATCH] Add basic captchaserver --- src/captchaserver.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/captchaserver.js diff --git a/src/captchaserver.js b/src/captchaserver.js new file mode 100644 index 00000000..22660022 --- /dev/null +++ b/src/captchaserver.js @@ -0,0 +1,30 @@ +/* + * serving captchas + */ + +import process from 'process'; +import http from 'http'; +import ppfunCaptcha from 'ppfun-captcha'; + +/* +const [ + PORT, + REDIS_URL, +] = process.argv.slice(2); +*/ +const PORT = 7000; + +const server = http.createServer((req, res) => { + const captcha = ppfunCaptcha.create(); + console.log(`Serving ${captcha.text} to ${req.headers['x-real-ip']}`); + res.writeHead(200, { + 'Content-Type': 'text/html', + 'Cache-Control': 'no-cache', + }); + res.write(captcha.data); + res.end(); +}); + +server.listen(port, () => { + console.log(`Captcha Server listening on port ${port}`); +});