tweaks
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
minisrv_service_file = true;
|
minisrv_service_file = true;
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
const proxyUrl = minisrv_config.services['wtv-proxy'].wrp_url;
|
const proxyUrl = minisrv_config.services[service_name].wrp_url;
|
||||||
if (!proxyUrl.endsWith('/')) {
|
if (!proxyUrl.endsWith('/')) {
|
||||||
proxyUrl += '/';
|
proxyUrl += '/';
|
||||||
}
|
}
|
||||||
// Remove 'wtv-proxy:/' from the start of request_url
|
|
||||||
let forwardPath = request_headers.request_url.replace(/^wtv-proxy:\//, '');
|
// Remove 'service_name:/' from the start of request_url
|
||||||
|
let forwardPath = request_headers.request_url
|
||||||
|
.replace(new RegExp(`^${service_name}:\\/`), '');
|
||||||
|
|
||||||
// Build the full URL to forward to
|
// Build the full URL to forward to
|
||||||
const targetUrl = proxyUrl + forwardPath;
|
const targetUrl = proxyUrl + forwardPath;
|
||||||
@@ -21,7 +23,6 @@ lib.get(targetUrl, (res) => {
|
|||||||
if (res.headers['content-type']) {
|
if (res.headers['content-type']) {
|
||||||
headers += `Content-Type: ${res.headers['content-type']}\n`;
|
headers += `Content-Type: ${res.headers['content-type']}\n`;
|
||||||
}
|
}
|
||||||
// Optionally copy other headers as needed
|
|
||||||
|
|
||||||
let data = [];
|
let data = [];
|
||||||
res.on('data', chunk => data.push(chunk));
|
res.on('data', chunk => data.push(chunk));
|
||||||
@@ -29,5 +30,6 @@ lib.get(targetUrl, (res) => {
|
|||||||
sendToClient(socket, headers, Buffer.concat(data));
|
sendToClient(socket, headers, Buffer.concat(data));
|
||||||
});
|
});
|
||||||
}).on('error', err => {
|
}).on('error', err => {
|
||||||
sendToClient(socket, '200 OK\nContent-Type: text/plain', `Error fetching image: ${err.message}`);
|
var errpage = WTVShared.doErrorPage(400, 'Error fetching image', err.message);
|
||||||
|
sendToClient(socket, errpage[0], errpage[1]);
|
||||||
});
|
});
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
minisrv_service_file = true;
|
minisrv_service_file = true;
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
const proxyUrl = minisrv_config.services['wtv-proxy'].wrp_url;
|
const proxyUrl = minisrv_config.services[service_name].wrp_url;
|
||||||
if (!proxyUrl.endsWith('/')) {
|
if (!proxyUrl.endsWith('/')) {
|
||||||
proxyUrl += '/';
|
proxyUrl += '/';
|
||||||
}
|
}
|
||||||
// Remove 'wtv-proxy:/' from the start of request_url
|
|
||||||
let forwardPath = request_headers.request_url.replace(/^wtv-proxy:\//, '');
|
// Remove 'service_name:/' from the start of request_url
|
||||||
|
let forwardPath = request_headers.request_url
|
||||||
|
.replace(new RegExp(`^${service_name}:\\/`), '');
|
||||||
|
|
||||||
// Build the full URL to forward to
|
// Build the full URL to forward to
|
||||||
var targetUrl = proxyUrl + forwardPath;
|
var targetUrl = proxyUrl + forwardPath;
|
||||||
@@ -20,7 +22,6 @@ if (!coords) {
|
|||||||
coords = '0,0'
|
coords = '0,0'
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Forwarding request to ${targetUrl} with coordinates ${coords}`);
|
|
||||||
targetUrl += `?${coords}`; // Append coordinates to the target URL
|
targetUrl += `?${coords}`; // Append coordinates to the target URL
|
||||||
|
|
||||||
lib.get(targetUrl, (res) => {
|
lib.get(targetUrl, (res) => {
|
||||||
@@ -29,7 +30,6 @@ lib.get(targetUrl, (res) => {
|
|||||||
if (res.headers['content-type']) {
|
if (res.headers['content-type']) {
|
||||||
headers += `Content-Type: ${res.headers['content-type']}\n`;
|
headers += `Content-Type: ${res.headers['content-type']}\n`;
|
||||||
}
|
}
|
||||||
// Optionally copy other headers as needed
|
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
res.on('data', chunk => data += chunk);
|
res.on('data', chunk => data += chunk);
|
||||||
@@ -54,12 +54,12 @@ lib.get(targetUrl, (res) => {
|
|||||||
if (urlInputMatch) {
|
if (urlInputMatch) {
|
||||||
pageUrl = urlInputMatch[1];
|
pageUrl = urlInputMatch[1];
|
||||||
}
|
}
|
||||||
var redirectUrl = `wtv-proxy:/proxy?id=${proxy_id}&t=${imgExt}&url=${encodeURIComponent(pageUrl)}`;
|
var redirectUrl = `${service_name}:/proxy?id=${proxy_id}&t=${imgExt}&url=${encodeURIComponent(pageUrl)}`;
|
||||||
sendToClient(socket, {'Status': 302, 'Location': redirectUrl}, '');
|
sendToClient(socket, {'Status': 302, 'Location': redirectUrl}, '');
|
||||||
} else {
|
} else {
|
||||||
var idx = data.indexOf('<BR>');
|
var idx = data.indexOf('<BR>');
|
||||||
data = data.substring(0, idx);
|
data = data.substring(0, idx);
|
||||||
var redirectUrl = `wtv-proxy:/proxy?err=${escape(data)}`;
|
var redirectUrl = `${service_name}:/proxy?err=${escape(data)}`;
|
||||||
sendToClient(socket, {'Status': 302, 'Location': redirectUrl}, '');
|
sendToClient(socket, {'Status': 302, 'Location': redirectUrl}, '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ proxyUrl = minisrv_config.services[service_name].wrp_url;
|
|||||||
if (!proxyUrl) {
|
if (!proxyUrl) {
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
wtv-expire-all: wtv-proxy:/`;
|
wtv-expire-all: ${service_name}:/`;
|
||||||
data = `
|
data = `
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -26,7 +26,7 @@ wtv-expire-all: wtv-proxy:/`;
|
|||||||
if (!request_headers.query.url) {
|
if (!request_headers.query.url) {
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
wtv-expire-all: wtv-proxy:/`;
|
wtv-expire-all: ${service_name}:/`;
|
||||||
data = `
|
data = `
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -80,7 +80,7 @@ wtv-expire-all: wtv-proxy:/`;
|
|||||||
|
|
||||||
if (params.get('Fn') === 'Home') {
|
if (params.get('Fn') === 'Home') {
|
||||||
headers = `302 Moved
|
headers = `302 Moved
|
||||||
Location: wtv-proxy:/proxy`
|
Location: ${service_name}:/proxy`
|
||||||
data = '';
|
data = '';
|
||||||
sendToClient(socket, headers, data);
|
sendToClient(socket, headers, data);
|
||||||
} else {
|
} else {
|
||||||
@@ -155,7 +155,7 @@ function process(content) {
|
|||||||
function finishPage(content, url = null) {
|
function finishPage(content, url = null) {
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
wtv-expire-all: wtv-proxy:/`;
|
wtv-expire-all: ${service_name}:/`;
|
||||||
data = `
|
data = `
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -163,7 +163,7 @@ wtv-expire-all: wtv-proxy:/`;
|
|||||||
</head>
|
</head>
|
||||||
<display nooptions skipback showwhencomplete>
|
<display nooptions skipback showwhencomplete>
|
||||||
<body bgcolor="#191919" text="#44cc55" link="36d5ff" vlink="36d5ff" fontsize="small">
|
<body bgcolor="#191919" text="#44cc55" link="36d5ff" vlink="36d5ff" fontsize="small">
|
||||||
<form method="POST" action="wtv-proxy:/proxy">
|
<form method="POST" action="${service_name}:/proxy">
|
||||||
<label for="url"> URL:</label>
|
<label for="url"> URL:</label>
|
||||||
<input type="text" id="url" name="url" value="${url || request_headers.query.url}" size=30>
|
<input type="text" id="url" name="url" value="${url || request_headers.query.url}" size=30>
|
||||||
<input type="hidden" name="z" value="${request_headers.query.z || '1.0'}">
|
<input type="hidden" name="z" value="${request_headers.query.z || '1.0'}">
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class WTVFTP {
|
|||||||
chunks.push(chunk);
|
chunks.push(chunk);
|
||||||
totalsize += chunk.length;
|
totalsize += chunk.length;
|
||||||
if (totalsize > 1024 * 1024 * 4) {
|
if (totalsize > 1024 * 1024 * 4) {
|
||||||
this.sendToClient(socket, { 'Status': '413 The file chosen contains too much information to be used.', 'Content-Type': 'text/plain' }, 'File too large');
|
this.sendToClient(socket, { 'Status': '413 The item chosen contains too much information to be used.', 'Content-Type': 'text/plain' }, 'Item too large');
|
||||||
ftpClient.end();
|
ftpClient.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,50 +331,47 @@ class WTVFavorites {
|
|||||||
keydata = this.fs.readFileSync(favoritefileout)
|
keydata = this.fs.readFileSync(favoritefileout)
|
||||||
console.log(newkey)
|
console.log(newkey)
|
||||||
switch(newkey) {
|
switch(newkey) {
|
||||||
case "F1":
|
case "F1":
|
||||||
keydata.F1.folder = folder;
|
keydata.F1.folder = folder;
|
||||||
break
|
break
|
||||||
case "F2":
|
case "F2":
|
||||||
keydata.F2 = {
|
keydata.F2 = {
|
||||||
folder: folder,
|
folder: folder,
|
||||||
id: id
|
id: id
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "F3":
|
||||||
|
keydata.F3 = {
|
||||||
|
folder: folder,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "F4":
|
||||||
|
keydata.F4 = {
|
||||||
|
folder: folder,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "F5":
|
||||||
|
keydata.F5 = {
|
||||||
|
folder: folder,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "F6":
|
||||||
|
keydata.F6 = {
|
||||||
|
folder: folder,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "F7":
|
||||||
|
keydata.F7 = {
|
||||||
|
folder: folder,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
if (oldkey != "none") {
|
||||||
case "F3":
|
|
||||||
keydata.F3 = {
|
|
||||||
folder: folder,
|
|
||||||
id: id
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "F4":
|
|
||||||
keydata.F4 = {
|
|
||||||
folder: folder,
|
|
||||||
id: id
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "F5":
|
|
||||||
keydata.F5 = {
|
|
||||||
folder: folder,
|
|
||||||
id: id
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "F6":
|
|
||||||
keydata.F6 = {
|
|
||||||
folder: folder,
|
|
||||||
id: id
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "F7":
|
|
||||||
keydata.F7 = {
|
|
||||||
folder: folder,
|
|
||||||
id: id
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (oldkey == "none")
|
|
||||||
{
|
|
||||||
//no
|
|
||||||
} else {
|
|
||||||
keydata[oldkey].folder = null;
|
keydata[oldkey].folder = null;
|
||||||
keydata[oldkey].id = null;
|
keydata[oldkey].id = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user