fix(control): read the PROXY protocol address for the join check #24

Merged
fristyagent merged 1 commits from fix/control-proxy-protocol-ip into main 2026-11-17 18:39:49 +03:00
Collaborator

📋 Description

A TCP tunnel with --allow rejects every client when the server sits behind a proxy that speaks
the PROXY protocol (Traefik proxyProtocol.version=2, HAProxy, nginx stream), even when the
client address matches the rule.

server/lib/proxy-front.js parses the PROXY header and stores the address on the socket as
frislitIp. server/lib/proxy.js reads it, which is why HTTP tunnels and the visitor log show the
real address. server/controllers/control.js never looked at it:

session.client = { id: randomToken(12), ip: forwarded || req.socket.remoteAddress || "", … };

With trustProxy off (the default, and correct here because TLS is passed through) forwarded is
null, so the join checked the allow list against the proxy container's address. registry.join()
then answered forbidden for everybody.

The control socket now derives the address the same way the HTTP path does, and the join log line
reports the same value instead of the raw peer address.

const clientIp = req.socket?.frislitIp || forwarded || req.socket.remoteAddress || "";

🚀 Changes made to ...

  • 🔧 Server
  • 🖥️ Client
  • ⌨️ CLI
  • 📚 Documentation
  • 🔄 Other: ___

✅ Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have tested my changes locally
  • I have looked for similar pull requests in the repository and found none

Tested by reproducing the report: frislit tcp 22 --allow <client-ip>/32 behind Traefik with
proxyProtocol.version=2 returns forbidden on frislit connect on 0.3.3. node --check on the
changed file passes; the server test suite runs in CI.

🔗 Related Issues

No issue: reported while setting up a TCP tunnel to a Windows machine.

## 📋 Description A TCP tunnel with `--allow` rejects every client when the server sits behind a proxy that speaks the PROXY protocol (Traefik `proxyProtocol.version=2`, HAProxy, nginx stream), even when the client address matches the rule. `server/lib/proxy-front.js` parses the PROXY header and stores the address on the socket as `frislitIp`. `server/lib/proxy.js` reads it, which is why HTTP tunnels and the visitor log show the real address. `server/controllers/control.js` never looked at it: ```js session.client = { id: randomToken(12), ip: forwarded || req.socket.remoteAddress || "", … }; ``` With `trustProxy` off (the default, and correct here because TLS is passed through) `forwarded` is null, so the join checked the allow list against the proxy container's address. `registry.join()` then answered `forbidden` for everybody. The control socket now derives the address the same way the HTTP path does, and the join log line reports the same value instead of the raw peer address. ```js const clientIp = req.socket?.frislitIp || forwarded || req.socket.remoteAddress || ""; ``` ## 🚀 Changes made to ... - [x] 🔧 Server - [ ] 🖥️ Client - [ ] ⌨️ CLI - [ ] 📚 Documentation - [ ] 🔄 Other: ___ ## ✅ Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have tested my changes locally - [x] I have looked for similar pull requests in the repository and found none Tested by reproducing the report: `frislit tcp 22 --allow <client-ip>/32` behind Traefik with `proxyProtocol.version=2` returns `forbidden` on `frislit connect` on 0.3.3. `node --check` on the changed file passes; the server test suite runs in CI. ## 🔗 Related Issues No issue: reported while setting up a TCP tunnel to a Windows machine.
fristyagent added 1 commit 2026-11-17 18:35:56 +03:00
fix(control): read the PROXY protocol address for the join check
CI / CLI (pull_request) Successful in 20s
CI / Server (pull_request) Successful in 26s
CI / Docker image (pull_request) Successful in 31s
CI / CLI (linux-arm64, static) (pull_request) Successful in 50s
CI / CLI (windows) (pull_request) Successful in 52s
CI / CLI (linux-x86-64, static) (pull_request) Successful in 1m1s
1e73e96482
HTTP requests already prefer socket.frislitIp, which the TLS front fills from
the PROXY protocol. The control socket ignored it, so the TCP join check
compared the allow list against the proxy address and rejected every client.
fristyagent merged commit e4df25681a into main 2026-11-17 18:39:49 +03:00
Sign in to join this conversation.