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);
}
if (!socket_sessions[socket.id]) {
socket.destroy();
if (socket.destroy) socket.destroy();
return;
}
if (!socket.res) {
@@ -1471,10 +1471,15 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
if (!headers) return;
if (headers["wtv-client-serial-number"] != null && socket.ssid == null) {
if (!wtvshared.checkSSID(headers["wtv-client-serial-number"])) {
// close socket for invalid ssid
cleanupSocket(socket)
return;
if (minisrv_config.config.require_valid_ssid) {
if (!wtvshared.checkSSID(headers["wtv-client-serial-number"])) {
// reject invalid SSIDs
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;
}
}
socket.ssid = wtvshared.makeSafeSSID(headers["wtv-client-serial-number"]);
if (socket.ssid != null) {