Skip to content

Commit

Permalink
change some tings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sensokaku authored Jun 8, 2021
1 parent 8c09f6d commit 1866e86
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,23 @@ const http = require('http');
const url = require('url');

const hostname = '127.0.0.1';
const postport = 3000;
const getport = 3001;
const postport = 4000;
const getport = 4001;

var a = [];

const postserver = http.createServer((req, res) => {
var q = url.parse(req.url, true).query;
var ip = req.headers["x-real-ip"];
if (ip) {
ip = ip.split(".");
ip[0] = "**";
if (ip.length > 3) {
ip[3] = "**";
}
ip = ip.join(".");
}
else {
ip = "";
}
q.ip = ip;
if (q.title || q.sid) {
q.ip = "Guest";
if (q.title || q.sid) {
a.push(q);
}
if (a.length > 16) {
a.shift();
}
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Access-Control-Allow-Origin', '*');
res.end("");
});

Expand All @@ -46,4 +35,3 @@ postserver.listen(postport, hostname, () => {
getserver.listen(getport, hostname, () => {
console.log(`Server running at http://${hostname}:${getport}/`);
});

0 comments on commit 1866e86

Please sign in to comment.