add catchall system & http pc server
- define a catchall name to run globally or per service - catchall must be javascript, but not necessarily a .js file - catchall can request async mode - catchall will catch any non-existing requests under its directory - see wtv-flashrom:/content/content-serve.js as an example, which will catch wtv-flashrom:/content/ URLs. - http pc: sends HTTP/1.0 to PC clients - can be disabled with `pc_server_hidden_service_enabled`: false - can change servicevault path by changing string of pc_server_hidden_service - get.js in default PC service vault to get any WTV Url on the service
This commit is contained in:
37
zefie_wtvp_minisrv/ServiceVault/http_pc/get.js
Normal file
37
zefie_wtvp_minisrv/ServiceVault/http_pc/get.js
Normal file
@@ -0,0 +1,37 @@
|
||||
if (request_headers.query.url) {
|
||||
if (request_headers.query.url.indexOf(":/") > 0) {
|
||||
var service_request = request_headers.query.url.split(":/")[0];
|
||||
var service_port = 0;
|
||||
Object.keys(minisrv_config.services).forEach(function (k) {
|
||||
if (minisrv_config.services[k].disabled) return;
|
||||
if (k == service_request) service_port = minisrv_config.services[k].port;
|
||||
});
|
||||
if (service_port > 0) {
|
||||
request_is_async = true;
|
||||
var request_headers_out = new Array()
|
||||
request_headers_out.request = "GET " + request_headers.query.url;
|
||||
request_headers_out.request_url = request_headers.query.url;
|
||||
request_headers_out['wtv-client-serial-number'] = socket.id + "HTTPPCReq";
|
||||
processURL(socket, request_headers_out);
|
||||
/*
|
||||
var s = require('net').Socket();
|
||||
var outdata = "";
|
||||
s.connect(service_port);
|
||||
s.setTimeout(1, function () {
|
||||
outdata = outdata.split()
|
||||
sendToClient(socket,outdata);
|
||||
});
|
||||
s.on('data', function (data) {
|
||||
outdata += data;
|
||||
});
|
||||
s.write()
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!headers) {
|
||||
var errpage = doErrorPage(500)
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
Reference in New Issue
Block a user