Fix: direct s2s connection not always possible
Trying to connect to a remote instance using direct s2s won't work if local instance has not the feature enabled, and if the remote instance does not know the local one. So using Websocket S2S in such case (that embed a discovery mecanism).
This commit is contained in:
parent
6434ff024d
commit
472caf9f5b
@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 7.0.1
|
||||
|
||||
* Fix: trying to connect to a remote instance using direct s2s won't work if local instance has not the feature enabled, and if the remote instance does not know the local one. So using Websocket S2S in such case (that embed a discovery mecanism).
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Importante Notes
|
||||
|
@ -5,16 +5,19 @@ local json = require "util.json";
|
||||
|
||||
local server_infos_dir = assert(module:get_option_string("peertubelivechat_server_infos_path", nil), "'peertubelivechat_server_infos_path' is a required option");
|
||||
local current_instance_url = assert(module:get_option_string("peertubelivechat_instance_url", nil), "'peertubelivechat_instance_url' is a required option");
|
||||
local no_outgoing_directs2s_to_peertube = module:get_option_boolean("s2s_peertubelivechat_no_outgoing_directs2s_to_peertube");
|
||||
|
||||
function discover_websocket_s2s(event)
|
||||
local to_host = event.to_host;
|
||||
module:log("debug", "Searching websocket s2s for remote host %s", to_host);
|
||||
|
||||
local f_s2s = io.open(path.join(server_infos_dir, to_host, 's2s'), "r");
|
||||
if f_s2s ~= nil then
|
||||
io.close(f_s2s);
|
||||
module:log("debug", "Remote host is a known Peertube %s that has s2s activated, we will let legacy s2s module handle the connection", to_host);
|
||||
return;
|
||||
if not no_outgoing_directs2s_to_peertube then
|
||||
local f_s2s = io.open(path.join(server_infos_dir, to_host, 's2s'), "r");
|
||||
if f_s2s ~= nil then
|
||||
io.close(f_s2s);
|
||||
module:log("debug", "Remote host is a known Peertube %s that has s2s activated, we will let legacy s2s module handle the connection", to_host);
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
local f_ws_proxy = io.open(path.join(server_infos_dir, to_host, 'ws-s2s'), "r");
|
||||
|
@ -52,14 +52,9 @@ function compatibleRemoteAuthenticatedConnectionEnabled (
|
||||
if (!('xmppserver' in livechatInfos)) { return false }
|
||||
if (!livechatInfos.xmppserver) { return false }
|
||||
|
||||
// FIXME: these tests does not really represent what Prosody will do.
|
||||
// Prosody can use Websocket in one way and Direct S2S in the other.
|
||||
// I don't really know what to test here.
|
||||
// In real case scenario, we should always have Websocket S2S on both side...
|
||||
// They are rare cases where Websocket is disabled on an entire server.
|
||||
// In such case, we indeed need direct S2S on both side.
|
||||
// So these tests should work.
|
||||
if (canWebsocketS2S && livechatInfos.xmppserver.websockets2s) { return true }
|
||||
// Note: see comments neer option s2s_peertubelivechat_no_outgoing_directs2s_to_peertube
|
||||
// to understand why we need both to be true.
|
||||
if (canDirectS2S && livechatInfos.xmppserver.directs2s) { return true }
|
||||
|
||||
return false
|
||||
|
@ -302,6 +302,12 @@ class ProsodyConfigContent {
|
||||
// FIXME: seems to be necessary to add the module on the muc host, so that dialback can trigger route/remote.
|
||||
this.muc.add('modules_enabled', 'websocket_s2s_peertubelivechat')
|
||||
|
||||
// Using direct S2S for outgoing connection can be an issue, if the local instance dont allow incomming S2S.
|
||||
// Indeed, the remote instance will not necessarely be able to discover the Websocket Endpoint.
|
||||
// To be sure the remote instance knows the websocket endpoint, we must use Websocket for the firt outgoing connect.
|
||||
// So, we will add a parameter for mod_s2s_peertubelivechat, to tell him not to use outgoint s2s connection.
|
||||
this.global.set('s2s_peertubelivechat_no_outgoing_directs2s_to_peertube', s2sPort === null)
|
||||
|
||||
this.muc.add('modules_enabled', 'dialback') // This allows s2s connections without certicicates!
|
||||
this.authenticated?.add('modules_enabled', 'dialback') // This allows s2s connections without certicicates!
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user