mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
Merge pull request #70 from schlagmichdoch/add_ip_debugging_flag
Add debug mode to enable debugging auto discovery
This commit is contained in:
commit
b9806d4327
2 changed files with 77 additions and 3 deletions
|
@ -30,7 +30,7 @@ Set options by using the following flags in the `docker run` command:
|
||||||
> - 3000 -> `-p 127.0.0.1:3000:3000`
|
> - 3000 -> `-p 127.0.0.1:3000:3000`
|
||||||
> - 8080 -> `-p 127.0.0.1:8080:3000`
|
> - 8080 -> `-p 127.0.0.1:8080:3000`
|
||||||
##### Rate limiting requests
|
##### Rate limiting requests
|
||||||
```
|
```bash
|
||||||
-e RATE_LIMIT=true
|
-e RATE_LIMIT=true
|
||||||
```
|
```
|
||||||
> Limits clients to 1000 requests per 5 min
|
> Limits clients to 1000 requests per 5 min
|
||||||
|
@ -70,6 +70,31 @@ Set options by using the following flags in the `docker run` command:
|
||||||
> }
|
> }
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
##### Debug Mode
|
||||||
|
```bash
|
||||||
|
-e DEBUG_MODE="true"
|
||||||
|
```
|
||||||
|
|
||||||
|
> Use this flag to enable debugging information about the connecting peers IP addresses. This is quite useful to check whether the [#HTTP-Server](#http-server)
|
||||||
|
> is configured correctly, so the auto discovery feature works correctly. Otherwise, all clients discover each other mutually, independently of their network status.
|
||||||
|
>
|
||||||
|
> If this flag is set to `"true"` each peer that connects to the PairDrop server will produce a log to STDOUT like this:
|
||||||
|
> ```
|
||||||
|
> ----DEBUGGING-PEER-IP-START----
|
||||||
|
> remoteAddress: ::ffff:172.17.0.1
|
||||||
|
> x-forwarded-for: 19.117.63.126
|
||||||
|
> cf-connecting-ip: undefined
|
||||||
|
> PairDrop uses: 19.117.63.126
|
||||||
|
> IP is private: false
|
||||||
|
> if IP is private, '127.0.0.1' is used instead
|
||||||
|
> ----DEBUGGING-PEER-IP-END----
|
||||||
|
> ```
|
||||||
|
> If the IP PairDrop uses is the public IP of your device everything is correctly setup.
|
||||||
|
>To find out your devices public IP visit https://www.whatismyip.com/.
|
||||||
|
>
|
||||||
|
> To preserve your clients' privacy, **never use this flag in production!**
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
### Docker Image from GHCR
|
### Docker Image from GHCR
|
||||||
|
@ -82,7 +107,7 @@ docker run -d --restart=unless-stopped --name=pairdrop -p 127.0.0.1:3000:3000 gh
|
||||||
>
|
>
|
||||||
> To specify options replace `npm run start:prod` according to [the documentation below.](#options--flags-1)
|
> To specify options replace `npm run start:prod` according to [the documentation below.](#options--flags-1)
|
||||||
|
|
||||||
> The Docker Image includes a Healthcheck. To learn more see [Docker Swarm Usage](./docker-swarm-usage.md#docker-swarm-usage)
|
> The Docker Image includes a Healthcheck. To learn more see [Docker Swarm Usage](docker-swarm-usage.md#docker-swarm-usage)
|
||||||
|
|
||||||
### Docker Image self-built
|
### Docker Image self-built
|
||||||
#### Build the image
|
#### Build the image
|
||||||
|
@ -103,7 +128,7 @@ docker run -d --restart=unless-stopped --name=pairdrop -p 127.0.0.1:3000:3000 -i
|
||||||
>
|
>
|
||||||
> To specify options replace `npm run start:prod` according to [the documentation below.](#options--flags-1)
|
> To specify options replace `npm run start:prod` according to [the documentation below.](#options--flags-1)
|
||||||
|
|
||||||
> The Docker Image includes a Healthcheck. To learn more see [Docker Swarm Usage](./docker-swarm-usage.md#docker-swarm-usage)
|
> The Docker Image includes a Healthcheck. To learn more see [Docker Swarm Usage](docker-swarm-usage.md#docker-swarm-usage)
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
@ -201,6 +226,36 @@ $env:RTC_CONFIG="rtc_config.json"; npm start
|
||||||
> }
|
> }
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
#### Debug Mode
|
||||||
|
On Unix based systems
|
||||||
|
```bash
|
||||||
|
DEBUG_MODE="true" npm start
|
||||||
|
```
|
||||||
|
On Windows
|
||||||
|
```bash
|
||||||
|
$env:DEBUG_MODE="true"; npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
> Use this flag to enable debugging information about the connecting peers IP addresses. This is quite useful to check whether the [#HTTP-Server](#http-server)
|
||||||
|
> is configured correctly, so the auto discovery feature works correctly. Otherwise, all clients discover each other mutually, independently of their network status.
|
||||||
|
>
|
||||||
|
> If this flag is set to `"true"` each peer that connects to the PairDrop server will produce a log to STDOUT like this:
|
||||||
|
> ```
|
||||||
|
> ----DEBUGGING-PEER-IP-START----
|
||||||
|
> remoteAddress: ::ffff:172.17.0.1
|
||||||
|
> x-forwarded-for: 19.117.63.126
|
||||||
|
> cf-connecting-ip: undefined
|
||||||
|
> PairDrop uses: 19.117.63.126
|
||||||
|
> IP is private: false
|
||||||
|
> if IP is private, '127.0.0.1' is used instead
|
||||||
|
> ----DEBUGGING-PEER-IP-END----
|
||||||
|
> ```
|
||||||
|
> If the IP PairDrop uses is the public IP of your device everything is correctly setup.
|
||||||
|
>To find out your devices public IP visit https://www.whatismyip.com/.
|
||||||
|
>
|
||||||
|
> To preserve your clients' privacy, **never use this flag in production!**
|
||||||
|
|
||||||
|
|
||||||
### Options / Flags
|
### Options / Flags
|
||||||
#### Local Run
|
#### Local Run
|
||||||
```bash
|
```bash
|
||||||
|
@ -257,6 +312,8 @@ npm run start:prod -- --localhost-only --include-ws-fallback
|
||||||
## HTTP-Server
|
## HTTP-Server
|
||||||
When running PairDrop, the `X-Forwarded-For` header has to be set by a proxy. Otherwise, all clients will be mutually visible.
|
When running PairDrop, the `X-Forwarded-For` header has to be set by a proxy. Otherwise, all clients will be mutually visible.
|
||||||
|
|
||||||
|
To check if your setup is configured correctly [use the environment variable `DEBUG_MODE="true"`](#debug-mode).
|
||||||
|
|
||||||
### Using nginx
|
### Using nginx
|
||||||
#### Allow http and https requests
|
#### Allow http and https requests
|
||||||
```
|
```
|
||||||
|
|
17
index.js
17
index.js
|
@ -90,6 +90,12 @@ if (process.argv.includes('--include-ws-fallback')) {
|
||||||
app.use(express.static('public'));
|
app.use(express.static('public'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const debugMode = process.env.DEBUG_MODE === "true";
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
console.log("DEBUG_MODE is active. To protect privacy, do not use in production.")
|
||||||
|
}
|
||||||
|
|
||||||
app.use(function(req, res) {
|
app.use(function(req, res) {
|
||||||
res.redirect('/');
|
res.redirect('/');
|
||||||
});
|
});
|
||||||
|
@ -502,6 +508,17 @@ class Peer {
|
||||||
if (this.ip.substring(0,7) === "::ffff:")
|
if (this.ip.substring(0,7) === "::ffff:")
|
||||||
this.ip = this.ip.substring(7);
|
this.ip = this.ip.substring(7);
|
||||||
|
|
||||||
|
if (debugMode) {
|
||||||
|
console.debug("----DEBUGGING-PEER-IP-START----");
|
||||||
|
console.debug("remoteAddress:", request.connection.remoteAddress);
|
||||||
|
console.debug("x-forwarded-for:", request.headers['x-forwarded-for']);
|
||||||
|
console.debug("cf-connecting-ip:", request.headers['cf-connecting-ip']);
|
||||||
|
console.debug("PairDrop uses:", this.ip);
|
||||||
|
console.debug("IP is private:", this.ipIsPrivate(this.ip));
|
||||||
|
console.debug("if IP is private, '127.0.0.1' is used instead");
|
||||||
|
console.debug("----DEBUGGING-PEER-IP-END----");
|
||||||
|
}
|
||||||
|
|
||||||
// IPv4 and IPv6 use different values to refer to localhost
|
// IPv4 and IPv6 use different values to refer to localhost
|
||||||
// put all peers on the same network as the server into the same room as well
|
// put all peers on the same network as the server into the same room as well
|
||||||
if (this.ip === '::1' || this.ipIsPrivate(this.ip)) {
|
if (this.ip === '::1' || this.ipIsPrivate(this.ip)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue