diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/proxy.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/proxy.js index b06bb8eb..ca1cfb4b 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/proxy.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/proxy.js @@ -2,68 +2,95 @@ minisrv_service_file = true; request_is_async = true; proxyUrl = minisrv_config.services[service_name].wrp_url; -if (!proxyUrl.endsWith('/')) { - proxyUrl += '/'; -} - -if (!request_headers.query.url) { +if (!proxyUrl) { headers = `200 OK -Content-Type: text/html`; +Content-Type: text/html +wtv-expire-all: wtv-proxy:/`; data = ` - + Web Rendering Proxy - - + +

Web Rendering Proxy

-

Welcome to the Web Rendering Proxy.
Please provide a valid URL to render.

-
- - - - - - - -
- -` + Sorry, the Web Rendering Proxy is not enabled on this service.
+ +`; sendToClient(socket, headers, data); -} else { - if (request_headers.query.err) { - finishPage(`

Error

${request_headers.query.err}

`).join('
'); +} else { + + if (!proxyUrl.endsWith('/')) { + proxyUrl += '/'; + } + + if (!request_headers.query.url) { + headers = `200 OK +Content-Type: text/html +wtv-expire-all: wtv-proxy:/`; + data = ` + + + Web Rendering Proxy + + +

Web Rendering Proxy

+

Welcome to the Web Rendering Proxy.
+ Please provide a valid URL to render.

+
+ + + + + + + + + +
+
+
+ Back to Tricks +
+ +` + sendToClient(socket, headers, data); } else { - const params = new URLSearchParams({ - url: request_headers.query.url, - z: request_headers.query.z || '1.0', - t: request_headers.query.t || 'jpg', - c: request_headers.query.c || '256', - m: request_headers.query.m || 'ismap' - }); - const fullUrl = proxyUrl + '?' + params.toString(); - const urlObj = new URL(fullUrl); - const lib = urlObj.protocol === 'https:' ? https : http; - if (request_headers.query.id) { - finishPage(``); + if (request_headers.query.err) { + finishPage(`

Error

${request_headers.query.err}

`).join('
'); } else { - function fetch(url) { - return new Promise((resolve, reject) => { - lib.get(url, (res) => { - let data = ''; - res.on('data', chunk => data += chunk); - res.on('end', () => resolve({ text: () => Promise.resolve(data) })); - }).on('error', reject); - }); + const params = new URLSearchParams({ + url: request_headers.query.url, + z: request_headers.query.z || '1.0', + t: request_headers.query.t || 'jpg', + c: request_headers.query.c || '256', + h: request_headers.query.h || '416', + w: request_headers.query.w || '640', + m: request_headers.query.m || 'ismap' + }); + const fullUrl = proxyUrl + '?' + params.toString(); + const urlObj = new URL(fullUrl); + const lib = urlObj.protocol === 'https:' ? https : http; + if (request_headers.query.id) { + finishPage(``); + } else { + function fetch(url) { + return new Promise((resolve, reject) => { + lib.get(url, (res) => { + let data = ''; + res.on('data', chunk => data += chunk); + res.on('end', () => resolve({ text: () => Promise.resolve(data) })); + }).on('error', reject); + }); + } + fetch(fullUrl) + .then(response => response.text()) + .then(text => { process(text); }) + .catch(err => { finishPage(`Error fetching page: ${err.message}`); }); } - fetch(fullUrl) - .then(response => response.text()) - .then(text => { process(text); }) - .catch(err => { finishPage(`Error fetching page: ${err.message}`); }); } } } - function process(content) { if (content.startsWith(' Web Rendering Proxy +
@@ -105,14 +134,11 @@ Content-Type: text/html`; + *
${content}
-
-
-Start Over -
`; sendToClient(socket, headers, data); -} \ No newline at end of file +} diff --git a/zefie_wtvp_minisrv/includes/config.json b/zefie_wtvp_minisrv/includes/config.json index c3a6e1a5..a9b8ef34 100644 --- a/zefie_wtvp_minisrv/includes/config.json +++ b/zefie_wtvp_minisrv/includes/config.json @@ -395,13 +395,12 @@ }, "wtv-search": { "disabled": true, - "port": 1695, - "searxng_url": "http://192.168.11.20:9999/" // replace with your own searxng instance + "port": 1695 + // "searxng_url": "" // replace with your own searxng instance }, "wtv-proxy": { - "disabled": true, - "port": 1696, - "wrp_url": "http://192.168.11.20:8889/" // replace with your own tenox9/wrp + "port": 1696 + // "wrp_url": "" // replace with your own tenox9/wrp }, "pb_services": { // PC Services for PageBuilder