util/prosodyctl/check.lua
changeset 11659 bbf50525faa5
parent 11658 52c7a0e74bb2
child 11780 1132a1f1ca5a
equal deleted inserted replaced
11658:52c7a0e74bb2 11659:bbf50525faa5
   363 			c2s_srv_required, s2s_srv_required = true, true;
   363 			c2s_srv_required, s2s_srv_required = true, true;
   364 		end
   364 		end
   365 
   365 
   366 		local v6_supported = not not socket.tcp6;
   366 		local v6_supported = not not socket.tcp6;
   367 
   367 
       
   368 		local function trim_dns_name(n)
       
   369 			return (n:gsub("%.$", ""));
       
   370 		end
       
   371 
   368 		for jid, host_options in enabled_hosts() do
   372 		for jid, host_options in enabled_hosts() do
   369 			local all_targets_ok, some_targets_ok = true, false;
   373 			local all_targets_ok, some_targets_ok = true, false;
   370 			local node, host = jid_split(jid);
   374 			local node, host = jid_split(jid);
   371 
   375 
   372 			local modules, component_module = modulemanager.get_modules_for_host(host);
   376 			local modules, component_module = modulemanager.get_modules_for_host(host);
   386 					for _, record in ipairs(res) do
   390 					for _, record in ipairs(res) do
   387 						if record.srv.target == "." then -- TODO is this an error if mod_c2s is enabled?
   391 						if record.srv.target == "." then -- TODO is this an error if mod_c2s is enabled?
   388 							print("    'xmpp-client' service disabled by pointing to '.'"); -- FIXME Explain better what this is
   392 							print("    'xmpp-client' service disabled by pointing to '.'"); -- FIXME Explain better what this is
   389 							break;
   393 							break;
   390 						end
   394 						end
   391 						target_hosts:add(record.srv.target);
   395 						local target = trim_dns_name(record.srv.target);
       
   396 						target_hosts:add(target);
   392 						if not c2s_ports:contains(record.srv.port) then
   397 						if not c2s_ports:contains(record.srv.port) then
   393 							print("    SRV target "..record.srv.target.." contains unknown client port: "..record.srv.port);
   398 							print("    SRV target "..target.." contains unknown client port: "..record.srv.port);
   394 						end
   399 						end
   395 					end
   400 					end
   396 				else
   401 				else
   397 					if c2s_srv_required then
   402 					if c2s_srv_required then
   398 						print("    No _xmpp-client SRV record found for "..host..", but it looks like you need one.");
   403 						print("    No _xmpp-client SRV record found for "..host..", but it looks like you need one.");
   408 					for _, record in ipairs(res) do
   413 					for _, record in ipairs(res) do
   409 						if record.srv.target == "." then -- TODO is this an error if mod_c2s is enabled?
   414 						if record.srv.target == "." then -- TODO is this an error if mod_c2s is enabled?
   410 							print("    'xmpps-client' service disabled by pointing to '.'"); -- FIXME Explain better what this is
   415 							print("    'xmpps-client' service disabled by pointing to '.'"); -- FIXME Explain better what this is
   411 							break;
   416 							break;
   412 						end
   417 						end
   413 						target_hosts:add(record.srv.target);
   418 						local target = trim_dns_name(record.srv.target);
       
   419 						target_hosts:add(target);
   414 						if not c2s_tls_ports:contains(record.srv.port) then
   420 						if not c2s_tls_ports:contains(record.srv.port) then
   415 							print("    SRV target "..record.srv.target.." contains unknown Direct TLS client port: "..record.srv.port);
   421 							print("    SRV target "..target.." contains unknown Direct TLS client port: "..record.srv.port);
   416 						end
   422 						end
   417 					end
   423 					end
   418 				else
   424 				else
   419 					print("    No _xmpps-client SRV record found for "..host..", but it looks like you need one.");
   425 					print("    No _xmpps-client SRV record found for "..host..", but it looks like you need one.");
   420 					all_targets_ok = false;
   426 					all_targets_ok = false;
   426 					for _, record in ipairs(res) do
   432 					for _, record in ipairs(res) do
   427 						if record.srv.target == "." then -- TODO Is this an error if mod_s2s is enabled?
   433 						if record.srv.target == "." then -- TODO Is this an error if mod_s2s is enabled?
   428 							print("    'xmpp-server' service disabled by pointing to '.'"); -- FIXME Explain better what this is
   434 							print("    'xmpp-server' service disabled by pointing to '.'"); -- FIXME Explain better what this is
   429 							break;
   435 							break;
   430 						end
   436 						end
   431 						target_hosts:add(record.srv.target);
   437 						local target = trim_dns_name(record.srv.target);
       
   438 						target_hosts:add(target);
   432 						if not s2s_ports:contains(record.srv.port) then
   439 						if not s2s_ports:contains(record.srv.port) then
   433 							print("    SRV target "..record.srv.target.." contains unknown server port: "..record.srv.port);
   440 							print("    SRV target "..target.." contains unknown server port: "..record.srv.port);
   434 						end
   441 						end
   435 					end
   442 					end
   436 				else
   443 				else
   437 					if s2s_srv_required then
   444 					if s2s_srv_required then
   438 						print("    No _xmpp-server SRV record found for "..host..", but it looks like you need one.");
   445 						print("    No _xmpp-server SRV record found for "..host..", but it looks like you need one.");
   443 				end
   450 				end
   444 			end
   451 			end
   445 			if target_hosts:empty() then
   452 			if target_hosts:empty() then
   446 				target_hosts:add(host);
   453 				target_hosts:add(host);
   447 			end
   454 			end
   448 
       
   449 			target_hosts = target_hosts / function(target) return target:gsub("%.$", ""); end
       
   450 
   455 
   451 			if target_hosts:contains("localhost") then
   456 			if target_hosts:contains("localhost") then
   452 				print("    Target 'localhost' cannot be accessed from other servers");
   457 				print("    Target 'localhost' cannot be accessed from other servers");
   453 				target_hosts:remove("localhost");
   458 				target_hosts:remove("localhost");
   454 			end
   459 			end