SnapDrop / snapdrop

A Progressive Web App for local file sharing
https://snapdrop.net
GNU General Public License v3.0
18.33k stars 1.68k forks source link

Check for CF-Connecting-IP and decreased timeout #544

Open skiby7 opened 1 year ago

skiby7 commented 1 year ago

When hosting Snapdrop behind Cloudflare, X-Forwarded-For is useless. Furthermore, I'm hosting my installation behind another internal proxy, so, in the end, X-Forwarder-For is set to the internal proxy's IP for all the peer, which can see each other regardless being on different networks. To fix this I made _setIP check if the header "cf-connecting-ip" exists, then sets the IP accordingly.

Lastly, when a peer changes network (e.g. a phone switches from wifi to mobile data), the function _leaveRoom is not called and the peer stays visible to others connected to the same room for a whole minute: I adjusted the timeout to what I think is a more reasonable value (500ms, so _leaveRoom is called after 1s).