fix SSID check, also make it optional

This commit is contained in:
zefie
2024-05-04 13:38:09 -04:00
parent 4e5adefb7b
commit 9f238be806
2 changed files with 11 additions and 5 deletions

View File

@@ -1124,7 +1124,7 @@ async function sendToClient(socket, headers_obj, data = null) {
headers_obj = headerStringToObj(headers_obj, true); headers_obj = headerStringToObj(headers_obj, true);
} }
if (!socket_sessions[socket.id]) { if (!socket_sessions[socket.id]) {
socket.destroy(); if (socket.destroy) socket.destroy();
return; return;
} }
if (!socket.res) { if (!socket.res) {
@@ -1471,11 +1471,16 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
if (!headers) return; if (!headers) return;
if (headers["wtv-client-serial-number"] != null && socket.ssid == null) { if (headers["wtv-client-serial-number"] != null && socket.ssid == null) {
if (minisrv_config.config.require_valid_ssid) {
if (!wtvshared.checkSSID(headers["wtv-client-serial-number"])) { if (!wtvshared.checkSSID(headers["wtv-client-serial-number"])) {
// close socket for invalid ssid // reject invalid SSIDs
cleanupSocket(socket) var errpage = wtvshared.doErrorPage(400, "minisrv ran into a technical problem. Reason: Your SSID is not valid.");
headers = errpage[0];
data = errpage[1];
sendToClient(socket, headers, data);
return; return;
} }
}
socket.ssid = wtvshared.makeSafeSSID(headers["wtv-client-serial-number"]); socket.ssid = wtvshared.makeSafeSSID(headers["wtv-client-serial-number"]);
if (socket.ssid != null) { if (socket.ssid != null) {
if (!ssid_sessions[socket.ssid]) { if (!ssid_sessions[socket.ssid]) {

View File

@@ -47,6 +47,7 @@
"allow_guests": true, // Allow users to experience the server without registering "allow_guests": true, // Allow users to experience the server without registering
"domain_name": "wtv.zefie.com", // For usenet and future stuff, no need to change just yet, "domain_name": "wtv.zefie.com", // For usenet and future stuff, no need to change just yet,
"max_post_length": 20, // in megabytes "max_post_length": 20, // in megabytes
"require_valid_ssid": true, // require a valid SSID (with valid CRC)
"user_accounts": { // user account settings "user_accounts": { // user account settings
"max_users_per_account": 6, // Max total users (including primary) per account "max_users_per_account": 6, // Max total users (including primary) per account
"min_username_length": 5, // minimum username length "min_username_length": 5, // minimum username length