revert tls hack, make prosody 0.12 compatible

This commit is contained in:
root 2023-02-24 23:24:02 +01:00
parent 505362164d
commit a0a40d4a7c
3 changed files with 5 additions and 33 deletions

View file

@ -15,7 +15,6 @@ local xmpp_server_key = module:get_option("http_upload_external_server_key");
local filetransfer_manager_ui_url = module:get_option("filetransfer_manager_ui_url");
-- imports
require"https";
local st = require"util.stanza";
local http = (string.len(external_url) >= 5 and string.sub(external_url,1,5) == "https") and require"ssl.https" or require"socket.http";
local json = require"util.json";

View file

@ -14,11 +14,9 @@ local external_url = module:get_option("http_upload_external_url");
local xmpp_server_key = module:get_option("http_upload_external_server_key");
-- imports
require"https";
local st = require"util.stanza";
local http = (string.len(external_url) >= 5 and string.sub(external_url,1,5) == "https") and require"ssl.https" or require"socket.http";
local json = require"util.json";
local ltn12 = require('ltn12');
-- namespace
--local xmlns_http_upload = "urn:xmpp:http:upload";
@ -67,20 +65,9 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
end
-- the request
--local respbody, statuscode = http.request(external_url, reqbody);
local resptable = {};
local res, statuscode = http.request{
url = external_url,
protocol = "tlsv1_2",
method = "POST",
headers = {
["content-type"] = "application/x-www-form-urlencoded",
["content-length"] = #reqbody
},
source = ltn12.source.string(reqbody),
sink = ltn12.sink.table(resptable)
};
local respbody = string.gsub(table.concat(resptable), "\\/", "/")
local respbody, statuscode = http.request(external_url, reqbody);
respbody = string.gsub(respbody, "\\/", "/")
module:log("info", "HTTPUPLOAD: resp " .. respbody);
local get_url = nil;
local put_url = nil;

View file

@ -14,11 +14,9 @@ local external_url = module:get_option("http_upload_external_url");
local xmpp_server_key = module:get_option("http_upload_external_server_key");
-- imports
require"https";
local st = require"util.stanza";
local http = (string.len(external_url) >= 5 and string.sub(external_url,1,5) == "https") and require"ssl.https" or require"socket.http";
local json = require"util.json";
local ltn12 = require('ltn12');
-- namespace
local xmlns_http_upload = "urn:xmpp:http:upload";
@ -66,20 +64,8 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
end
-- the request
--local respbody, statuscode = http.request(external_url, reqbody);
local resptable = {};
local res, statuscode = http.request{
url = external_url,
protocol = "tlsv1_2",
method = "POST",
headers = {
["content-type"] = "application/x-www-form-urlencoded",
["content-length"] = #reqbody
},
source = ltn12.source.string(reqbody),
sink = ltn12.sink.table(resptable)
};
local respbody = string.gsub(table.concat(resptable), "\\/", "/")
local respbody, statuscode = http.request(external_url, reqbody);
respbody = string.gsub(respbody, "\\/", "/")
local get_url = nil;
local put_url = nil;