|
@@ -37,7 +37,7 @@ local ASAPKeyServer
|
37
|
37
|
= module:get_option_string("asap_key_server");
|
38
|
38
|
|
39
|
39
|
if ASAPKeyServer then
|
40
|
|
- module:log("info", "ASAP Public Key URL %s", ASAPKeyServer);
|
|
40
|
+ module:log("debug", "ASAP Public Key URL %s", ASAPKeyServer);
|
41
|
41
|
token_util:set_asap_key_server(ASAPKeyServer);
|
42
|
42
|
end
|
43
|
43
|
|
|
@@ -56,13 +56,13 @@ local ASAPAudience
|
56
|
56
|
local ASAPAcceptedIssuers
|
57
|
57
|
= module:get_option_array('asap_accepted_issuers',{'jibri-queue'});
|
58
|
58
|
|
59
|
|
-module:log("info", "ASAP Accepted Issuers %s", ASAPAcceptedIssuers);
|
|
59
|
+module:log("debug", "ASAP Accepted Issuers %s", ASAPAcceptedIssuers);
|
60
|
60
|
token_util:set_asap_accepted_issuers(ASAPAcceptedIssuers);
|
61
|
61
|
|
62
|
62
|
local ASAPAcceptedAudiences
|
63
|
63
|
= module:get_option_array('asap_accepted_audiences',{'*'});
|
64
|
64
|
|
65
|
|
-module:log("info", "ASAP Accepted Audiences %s", ASAPAcceptedAudiences);
|
|
65
|
+module:log("debug", "ASAP Accepted Audiences %s", ASAPAcceptedAudiences);
|
66
|
66
|
token_util:set_asap_accepted_audiences(ASAPAcceptedAudiences);
|
67
|
67
|
|
68
|
68
|
-- do not require room to be set on tokens for jibri queue
|
|
@@ -112,7 +112,7 @@ end
|
112
|
112
|
log("info", "Starting jibri queue handling for %s", muc_component_host);
|
113
|
113
|
|
114
|
114
|
local external_api_url = module:get_option_string("external_api_url",tostring(parentHostName));
|
115
|
|
-module:log("info", "External advertised API URL", external_api_url);
|
|
115
|
+module:log("debug", "External advertised API URL", external_api_url);
|
116
|
116
|
|
117
|
117
|
-- Read ASAP key once on module startup
|
118
|
118
|
local f = io.open(ASAPKeyPath, "r");
|
|
@@ -179,11 +179,11 @@ end
|
179
|
179
|
local function sendIq(participant,action,requestId,time,position,token)
|
180
|
180
|
local iqId = uuid_gen();
|
181
|
181
|
local from = module:get_host();
|
182
|
|
- module:log("info","Oubound iq id %s",iqId);
|
|
182
|
+-- module:log("info","Oubound iq id %s",iqId);
|
183
|
183
|
local outStanza = st.iq({type = 'set', from = from, to = participant, id = iqId}):tag("jibri-queue",
|
184
|
184
|
{ xmlns = 'http://jitsi.org/protocol/jibri-queue', requestId = requestId, action = action });
|
185
|
185
|
|
186
|
|
- module:log("info","Oubound base stanza %s",inspect(outStanza));
|
|
186
|
+-- module:log("info","Oubound base stanza %s",inspect(outStanza));
|
187
|
187
|
|
188
|
188
|
if token then
|
189
|
189
|
outStanza:tag("token"):text(token):up()
|
|
@@ -194,7 +194,7 @@ local function sendIq(participant,action,requestId,time,position,token)
|
194
|
194
|
if position then
|
195
|
195
|
outStanza:tag("position"):text(tostring(position)):up()
|
196
|
196
|
end
|
197
|
|
- module:log("info","Oubound stanza %s",inspect(outStanza));
|
|
197
|
+ -- module:log("debug","Oubound stanza %s",inspect(outStanza));
|
198
|
198
|
module:send(outStanza);
|
199
|
199
|
end
|
200
|
200
|
|
|
@@ -245,13 +245,17 @@ local function sendEvent(type,room_address,participant,requestId,replyIq,replyEr
|
245
|
245
|
if code_ == 200 or code_ == 204 then
|
246
|
246
|
module:log("debug", "URL Callback: Code %s, Content %s, Request (host %s, path %s, body %s), Response: %s",
|
247
|
247
|
code_, content_, request_.host, request_.path, inspect(request_.body), inspect(response_));
|
248
|
|
- module:log("info", "sending reply IQ %s",inspect(replyIq));
|
249
|
|
- module:send(replyIq);
|
|
248
|
+ if (replyIq) then
|
|
249
|
+ module:log("debug", "sending reply IQ %s",inspect(replyIq));
|
|
250
|
+ module:send(replyIq);
|
|
251
|
+ end
|
250
|
252
|
else
|
251
|
253
|
module:log("warn", "URL Callback non successful: Code %s, Content %s, Request (%s), Response: %s",
|
252
|
254
|
code_, content_, inspect(request_), inspect(response_));
|
253
|
|
- module:log("warn", "sending reply error IQ %s",inspect(replyError));
|
254
|
|
- module:send(replyError);
|
|
255
|
+ if (replyError) then
|
|
256
|
+ module:log("warn", "sending reply error IQ %s",inspect(replyError));
|
|
257
|
+ module:send(replyError);
|
|
258
|
+ end
|
255
|
259
|
end
|
256
|
260
|
end);
|
257
|
261
|
end
|
|
@@ -265,15 +269,13 @@ function on_iq(event)
|
265
|
269
|
end
|
266
|
270
|
if event.stanza.attr.to == module:get_host() then
|
267
|
271
|
if event.stanza.attr.type == "set" then
|
268
|
|
- log("info", "Jibri Queue Messsage Event found: %s ",inspect(event.stanza));
|
269
|
272
|
local reply = st.reply(event.stanza);
|
270
|
273
|
local replyError = st.error_reply(event.stanza,'cancel','internal-server-error',"Queue Server Error");
|
271
|
|
- module:log("info","Reply stanza %s",inspect(reply));
|
272
|
274
|
|
273
|
275
|
local jibriQueue
|
274
|
276
|
= event.stanza:get_child('jibri-queue', 'http://jitsi.org/protocol/jibri-queue');
|
275
|
277
|
if jibriQueue then
|
276
|
|
- module:log("info", "Jibri Queue Request: %s ",inspect(jibriQueue));
|
|
278
|
+ module:log("debug", "Received Jibri Queue Request: %s ",inspect(jibriQueue));
|
277
|
279
|
|
278
|
280
|
local roomAddress = jibriQueue.attr.room;
|
279
|
281
|
local room = get_room_from_jid(room_jid_match_rewrite(roomAddress));
|
|
@@ -295,21 +297,26 @@ function on_iq(event)
|
295
|
297
|
if action == 'join' then
|
296
|
298
|
-- join action, so send event out
|
297
|
299
|
requestId = uuid_gen();
|
|
300
|
+ module:log("debug","Received join queue request for jid %s occupant %s requestId %s",roomAddress,occupant.jid,requestId);
|
298
|
301
|
|
299
|
302
|
-- now handle new jibri queue message
|
300
|
303
|
room.jibriQueue[occupant.jid] = requestId;
|
301
|
304
|
reply:add_child(st.stanza("jibri-queue", { xmlns = 'http://jitsi.org/protocol/jibri-queue', requestId = requestId})):up()
|
302
|
305
|
replyError:add_child(st.stanza("jibri-queue", { xmlns = 'http://jitsi.org/protocol/jibri-queue', requestId = requestId})):up()
|
303
|
306
|
|
304
|
|
- module:log("info","Sending JoinQueue event for jid %s occupant %s reply %s",roomAddress,occupant.jid,inspect(reply));
|
|
307
|
+ module:log("debug","Sending JoinQueue event for jid %s occupant %s reply %s",roomAddress,occupant.jid,inspect(reply));
|
305
|
308
|
sendEvent('JoinQueue',roomAddress,occupant.jid,requestId,reply,replyError);
|
306
|
309
|
end
|
307
|
310
|
if action == 'leave' then
|
308
|
311
|
requestId = jibriQueue.attr.requestId;
|
|
312
|
+ module:log("debug","Received leave queue request for jid %s occupant %s requestId %s",roomAddress,occupant.jid,requestId);
|
|
313
|
+
|
309
|
314
|
-- TODO: check that requestId is the same as cached value
|
310
|
315
|
room.jibriQueue[occupant.jid] = nil;
|
311
|
316
|
reply:add_child(st.stanza("jibri-queue", { xmlns = 'http://jitsi.org/protocol/jibri-queue', requestId = requestId})):up()
|
312
|
317
|
replyError:add_child(st.stanza("jibri-queue", { xmlns = 'http://jitsi.org/protocol/jibri-queue', requestId = requestId})):up()
|
|
318
|
+
|
|
319
|
+ module:log("debug","Sending LeaveQueue event for jid %s occupant %s reply %s",roomAddress,occupant.jid,inspect(reply));
|
313
|
320
|
sendEvent('LeaveQueue',roomAddress,occupant.jid,requestId,reply,replyError);
|
314
|
321
|
end
|
315
|
322
|
else
|
|
@@ -368,7 +375,7 @@ module:hook("iq/host", on_iq);
|
368
|
375
|
-- executed on every host added internally in prosody, including components
|
369
|
376
|
function process_host(host)
|
370
|
377
|
if host == muc_component_host then -- the conference muc component
|
371
|
|
- module:log("info","Hook to muc events on %s", host);
|
|
378
|
+ module:log("debug","Hook to muc events on %s", host);
|
372
|
379
|
|
373
|
380
|
local muc_module = module:context(host);
|
374
|
381
|
muc_module:hook("muc-room-created", room_created, -1);
|
|
@@ -379,7 +386,7 @@ function process_host(host)
|
379
|
386
|
end
|
380
|
387
|
|
381
|
388
|
if prosody.hosts[muc_component_host] == nil then
|
382
|
|
- module:log("info","No muc component found, will listen for it: %s", muc_component_host)
|
|
389
|
+ module:log("debug","No muc component found, will listen for it: %s", muc_component_host)
|
383
|
390
|
|
384
|
391
|
-- when a host or component is added
|
385
|
392
|
prosody.events.add_handler("host-activated", process_host);
|
|
@@ -430,7 +437,6 @@ end
|
430
|
437
|
-- @param event the http event, holds the request query
|
431
|
438
|
-- @return GET response, containing a json with response details
|
432
|
439
|
function handle_update_jibri_queue(event)
|
433
|
|
- module:log("info","Update Jibri Queue Event Received");
|
434
|
440
|
-- if (not event.request.url.query) then
|
435
|
441
|
-- return { status_code = 400; };
|
436
|
442
|
-- end
|
|
@@ -438,7 +444,7 @@ function handle_update_jibri_queue(event)
|
438
|
444
|
local body = json.decode(event.request.body);
|
439
|
445
|
-- local params = parse(event.request.url.query);
|
440
|
446
|
|
441
|
|
- module:log("info","Update Jibri Event Body %s",inspect(body));
|
|
447
|
+ module:log("debug","Update Jibri Queue Event Received: %s",inspect(body));
|
442
|
448
|
|
443
|
449
|
-- local token = params["token"];
|
444
|
450
|
local token
|
|
@@ -449,7 +455,7 @@ function handle_update_jibri_queue(event)
|
449
|
455
|
else
|
450
|
456
|
local prefixStart, prefixEnd = token:find("Bearer ");
|
451
|
457
|
if prefixStart ~= 1 then
|
452
|
|
- module:log("error", "Invalid authorization header format. The header must start with the string 'Bearer '");
|
|
458
|
+ module:log("error", "REST event: Invalid authorization header format. The header must start with the string 'Bearer '");
|
453
|
459
|
return 403
|
454
|
460
|
end
|
455
|
461
|
token = token:sub(prefixEnd + 1);
|
|
@@ -467,23 +473,24 @@ function handle_update_jibri_queue(event)
|
467
|
473
|
local room_jid = room_jid_match_rewrite(roomAddress);
|
468
|
474
|
|
469
|
475
|
if not verify_token(token, room_jid, {}) then
|
|
476
|
+ log("error", "REST event: Invalid token for room %s to route action %s for requestId %s", roomAddress, action, requestId);
|
470
|
477
|
return { status_code = 403; };
|
471
|
478
|
end
|
472
|
479
|
|
473
|
480
|
local room = get_room_from_jid(room_jid);
|
474
|
481
|
if (not room) then
|
475
|
|
- log("error", "no room found %s", roomAddress);
|
|
482
|
+ log("error", "REST event: no room found %s to route action %s for requestId %s", roomAddress, action, requestId);
|
476
|
483
|
return { status_code = 404; };
|
477
|
484
|
end
|
478
|
485
|
|
479
|
486
|
local occupant = room:get_occupant_by_real_jid(user_jid);
|
480
|
487
|
if not occupant then
|
481
|
|
- log("warn", "No occupant %s found for %s", user_jid, roomAddress);
|
|
488
|
+ log("warn", "REST event: No occupant %s found for %s to route action %s for requestId %s", user_jid, roomAddress, action, requestId);
|
482
|
489
|
return { status_code = 404; };
|
483
|
490
|
end
|
484
|
491
|
|
485
|
492
|
if not room.jibriQueue[occupant.jid] then
|
486
|
|
- log("warn", "No queue request found for occupant %s in conference %s",occupant.jid,room.jid)
|
|
493
|
+ log("warn", "REST event: No queue request found for occupant %s in conference %s to route action %s for requestId %s",occupant.jid,room.jid, action, requestId)
|
487
|
494
|
return { status_code = 404; };
|
488
|
495
|
end
|
489
|
496
|
|
|
@@ -499,7 +506,7 @@ function handle_update_jibri_queue(event)
|
499
|
506
|
requestId = room.jibriQueue[occupant.jid];
|
500
|
507
|
end
|
501
|
508
|
|
502
|
|
- -- TODO: actually implement udpate code here
|
|
509
|
+ log("debug", "REST event: Sending update for occupant %s in conference %s to route action %s for requestId %s",occupant.jid,room.jid, action, requestId)
|
503
|
510
|
sendIq(occupant.jid,action,requestId,time,position,userJWT);
|
504
|
511
|
return { status_code = 200; };
|
505
|
512
|
end
|