finish potential fix

This commit is contained in:
zefie
2022-10-06 14:56:29 -07:00
parent 4c26d972fe
commit 63dd5471a5

View File

@@ -568,36 +568,25 @@ async function processURL(socket, request_headers) {
var shortURL_service_path = shortURL_split.join(":"); var shortURL_service_path = shortURL_split.join(":");
shortURL = shortURL_service_name + ":/" + shortURL_service_path; shortURL = shortURL_service_name + ":/" + shortURL_service_path;
} else if (shortURL.indexOf(":") == -1 && request_headers.request.indexOf("HTTP/1") > 0 && request_headers.Host && socket.ssid == null) { } else if (shortURL.indexOf(":") == -1 && request_headers.request.indexOf("HTTP/1") > 0 && request_headers.Host && socket.ssid == null) {
if (request_headers.Host) { // PC browsers typically send a Host header
// PC browsers typically send a Host header if (minisrv_config.services.pc_services) {
if (minisrv_config.services.pc_services) { if (!minisrv_config.services.pc_services.disabled) {
if (!minisrv_config.services.pc_services.disabled) { socket.minisrv_pc_mode = true;
socket.minisrv_pc_mode = true; service_name = verifyServicePort("pc_services", socket);
service_name = verifyServicePort("pc_services", socket); if (!service_name) {
if (!service_name) { if (minisrv_config.services.pc_services.drop_connection_on_wrong_port) {
if (minisrv_config.services.pc_services.drop_connection_on_wrong_port) { // just close the connection, no fancy error
// just close the connection, no fancy error socket.end();
socket.end();
return;
}
var errpage = wtvshared.doErrorPage(500, null, socket.minisrv_pc_mode);
socket_sessions[socket.id].close_me = true;
sendToClient(socket, errpage[0], errpage[1]);
return; return;
} }
// if a directory, request index var errpage = wtvshared.doErrorPage(500, null, socket.minisrv_pc_mode);
if (shortURL.substring(shortURL.length - 1) == "/") shortURL += "index";
shortURL = service_name + ":" + shortURL;
} else {
// minimal pc mode to send error
socket.minisrv_pc_mode = true;
var errpage = wtvshared.doErrorPage(401, "PC services are disabled on this server", socket.minisrv_pc_mode);
headers = errpage[0];
data = errpage[1]
socket_sessions[socket.id].close_me = true; socket_sessions[socket.id].close_me = true;
sendToClient(socket, headers, data); sendToClient(socket, errpage[0], errpage[1]);
return; return;
} }
// if a directory, request index
if (shortURL.substring(shortURL.length - 1) == "/") shortURL += "index";
shortURL = service_name + ":" + shortURL;
} else { } else {
// minimal pc mode to send error // minimal pc mode to send error
socket.minisrv_pc_mode = true; socket.minisrv_pc_mode = true;
@@ -608,6 +597,15 @@ async function processURL(socket, request_headers) {
sendToClient(socket, headers, data); sendToClient(socket, headers, data);
return; return;
} }
} else {
// minimal pc mode to send error
socket.minisrv_pc_mode = true;
var errpage = wtvshared.doErrorPage(401, "PC services are disabled on this server", socket.minisrv_pc_mode);
headers = errpage[0];
data = errpage[1]
socket_sessions[socket.id].close_me = true;
sendToClient(socket, headers, data);
return;
} }
} }