Merge 0.9->0.10 (third time lucky)
authorMatthew Wild <mwild1@gmail.com>
Fri, 27 Mar 2015 22:11:58 +0000 (22:11 +0000)
committerMatthew Wild <mwild1@gmail.com>
Fri, 27 Mar 2015 22:11:58 +0000 (22:11 +0000)
1  2 
core/sessionmanager.lua
net/http/server.lua
plugins/mod_http.lua
tests/test.lua
util-src/encodings.c

index 476de931f7621efa0af6055510f72a2b7d6d704c,4b014d18cd5aea4002bbee1e67985291e709a0bb..8767e869e9d8c93b1e320b3677b934ef382b5b47
@@@ -114,19 -113,9 +114,19 @@@ en
  -- returns nil, err_type, err, err_message on failure
  function bind_resource(session, resource)
        if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end
-       if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end
+       if session.resource then return nil, "cancel", "not-allowed", "Cannot bind multiple resources on a single connection"; end
        -- We don't support binding multiple resources
  
 +      local event_payload = { session = session, resource = resource };
 +      if hosts[session.host].events.fire_event("pre-resource-bind", event_payload) == false then
 +              local err = event_payload.error;
 +              if err then return nil, err.type, err.condition, err.text; end
 +              return nil, "cancel", "not-allowed";
 +      else
 +              -- In case a plugin wants to poke at it
 +              resource = event_payload.resource;
 +      end
 +
        resource = resourceprep(resource);
        resource = resource ~= "" and resource or uuid_generate();
        --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing
Simple merge
index 8bda1cac2ea5703536c6ad6b3d6acf1f4d8c7828,9b574bc8eff9c45985174ff1e20c9cdd91dbdeb1..086887fbcc9a9b63ccd078c3a65804481d12a419
@@@ -118,8 -112,14 +120,14 @@@ function module.add_host(module
                                module:log("error", "Invalid route in %s, %q. See http://prosody.im/doc/developers/http#routes", app_name, key);
                        end
                end
+               local services = portmanager.get_active_services();
+               if services:get("https") or services:get("http") then
+                       module:log("debug", "Serving '%s' at %s", app_name, module:http_url(app_name, app_path));
+               else
+                       module:log("warn", "Not listening on any ports, '%s' will be unreachable", app_name);
+               end
        end
 -      
 +
        local function http_app_removed(event)
                local app_handlers = apps[event.item.name];
                apps[event.item.name] = nil;
diff --cc tests/test.lua
index f7475a805d1395e9c379aa7534f9ecff15a41b89,de1e40fd8bb96166154cf78f16a6ccc08d2dac81..78f2b234e3b3b5d5c6c2c76dfbc0981210ccad2e
@@@ -17,11 -18,11 +17,12 @@@ function run_all_tests(
        dotest "core.stanza_router"
        dotest "core.s2smanager"
        dotest "core.configmanager"
 +      dotest "util.ip"
        dotest "util.stanza"
        dotest "util.sasl.scram"
 -      
 +
        dosingletest("test_sasl.lua", "latin1toutf8");
+       dosingletest("test_utf8.lua", "valid");
  end
  
  local verbosity = tonumber(arg[1]) or 2;
index 2d5d49d497f70448f2f5f22185e076dcd487a8fa,91826ca42f3b682fbd196b5d0ca1e7ad2d256ec0..529a6c22832b58575a1df6be597ee6840aee7bd9
@@@ -370,21 -458,30 +457,26 @@@ LUALIB_API int luaopen_util_encodings(l
  #ifdef USE_STRINGPREP_ICU
        init_icu();
  #endif
 -      luaL_register(L, "encodings", Reg);
 +      lua_newtable(L);
  
 -      lua_pushliteral(L, "base64");
        lua_newtable(L);
        luaL_register(L, NULL, Reg_base64);
 -      lua_settable(L,-3);
 +      lua_setfield(L, -2, "base64");
  
 -      lua_pushliteral(L, "stringprep");
        lua_newtable(L);
        luaL_register(L, NULL, Reg_stringprep);
 -      lua_settable(L,-3);
 +      lua_setfield(L, -2, "stringprep");
  
 -      lua_pushliteral(L, "idna");
        lua_newtable(L);
        luaL_register(L, NULL, Reg_idna);
 -      lua_settable(L,-3);
 +      lua_setfield(L, -2, "idna");
  
 -      lua_pushliteral(L, "utf8");
+       lua_newtable(L);
+       luaL_register(L, NULL, Reg_utf8);
 -      lua_settable(L, -3);
++      lua_setfield(L, -2, "utf8");
+       lua_pushliteral(L, "version");                  /** version */
        lua_pushliteral(L, "-3.14");
 -      lua_settable(L,-3);
 +      lua_setfield(L, -2, "version");
        return 1;
  }