Skip to content

Commit

Permalink
Check for CF-Connecting-IP and decreased timeout (snapdrop pr SnapDro…
Browse files Browse the repository at this point in the history
  • Loading branch information
dxlliv committed May 28, 2023
1 parent f40a806 commit c6c0f24
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class SnapdropServer {

_keepAlive(peer) {
this._cancelKeepAlive(peer);
var timeout = 30000;
var timeout = 500;
if (!peer.lastBeat) {
peer.lastBeat = Date.now();
}
Expand Down Expand Up @@ -183,7 +183,9 @@ class Peer {
}

_setIP(request) {
if (request.headers['x-forwarded-for']) {
if (request.headers['cf-connecting-ip']) {
this.ip = request.headers['cf-connecting-ip'].split(/\s*,\s*/)[0];
} else if (request.headers['x-forwarded-for']) {
this.ip = request.headers['x-forwarded-for'].split(/\s*,\s*/)[0];
} else {
this.ip = request.connection.remoteAddress;
Expand Down

0 comments on commit c6c0f24

Please sign in to comment.