added https

This commit is contained in:
array-in-a-matrix 2022-05-08 15:33:16 -04:00
parent c9065cc86a
commit cd7cb28280
3 changed files with 25 additions and 7 deletions

3
.gitignore vendored
View file

@ -1,2 +1,3 @@
node_modules
*.log
ip-addresses.log
cert

View file

@ -1,5 +1,13 @@
# IP Grabber
Logs the client IPv4 address and redirects them to a target website using Node.js.
The grabber will redirect the client to the first commandline argument (a link or IP) if it exists. Otherwise, it will use the default link defined in the code. A Node.js server will be hosted on port 3030 (by default) when script is running.
If you plan on using this script, edit where the `address.log` file is created.
The grabber will redirect the client to the first commandline argument (a link or IP) if it exists. Otherwise, it will use the default link defined in the code. 2 Node.js servers will be hosted on port 3030 (HTTP) and port 3031 (HTTPS) by default.
If you plan on using HTTPS, you can generate a certificate using these commands:
```sh
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
mkdir cert && mv cert.pem key.pem cert && rm csr.pem
```

View file

@ -1,18 +1,26 @@
const connect = require('connect');
const http = require('http');
const https = require('https');
const file = require('fs');
const requestIp = require('request-ip');
const redirect = require('connect-redirection')
let redirectURL = 'https://arrayinamatrix.xyz/res/site/images/trollface.gif'
const redirectURL = 'https://arrayinamatrix.xyz/res/site/images/trollface.gif'
if (process.argv[2] != undefined) {
redirectURL = process.argv[2]
}
let logFile = 'ip-addresses.log'
let httpPort = 3030
const logFile = 'ip-addresses.log'
const httpPort = 3030
const httpsPort = 3031
const options = {
key: file.readFileSync('cert/key.pem'),
cert: file.readFileSync('cert/cert.pem')
};
console.log(`Redirect: ${redirectURL}`);
console.log(`Port: ${httpPort}`)
console.log(`HTTP Port: ${httpPort}`)
console.log(`HTTPS Port: ${httpsPort}`)
console.log(`Log file location: ${logFile}`)
console.log("########## IP LOGGER STARTED ##########");
@ -45,3 +53,4 @@ const app = connect()
});
http.createServer(app).listen(httpPort);
https.createServer(options, app).listen(httpsPort);