Skip to content

Commit 2e53f8b

Browse files
committed
Require non-empty user agent
1 parent 714c86e commit 2e53f8b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

doc/protocol.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,7 @@ Multiple set messages may be sent in one message where each message is separated
119119
120120
4005 Closed to protect your security
121121
When the client does something that compromises its security and the server closes the connection to force the client to fix its code.
122+
123+
4006 Identify yourself
124+
When the client is not providing sufficient information in the User-Agent header.
122125
```

src/server.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ wss.on('connection', (ws, req) => {
121121
return;
122122
}
123123

124+
if (!req.headers['user-agent']) {
125+
logger.info('A connection was closed for lacking a valid user-agent.');
126+
ws.send('Please provide a valid User-Agent header as required by https://docs.turbowarp.org/cloud-variables#advanced. If you use a cloud variable library, contact the author to find out how to do that.');
127+
ws.close(4006);
128+
return;
129+
}
130+
124131
const client = new Client(ws, req);
125132

126133
let isHandshaking = false;

0 commit comments

Comments
 (0)