]> granicus.if.org Git - ejabberd/commitdiff
Uncomment forgotten block of code
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 12 Nov 2016 11:51:43 +0000 (14:51 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 12 Nov 2016 11:51:43 +0000 (14:51 +0300)
src/ejabberd_service.erl

index 94cd68ecf79d286859d9f524bb82c9d904760fd9..35cfe15af522558c152fdb34a61ced7f46746eb6 100644 (file)
@@ -170,37 +170,28 @@ wait_for_stream(closed, StateData) ->
 wait_for_handshake({xmlstreamelement, El}, StateData) ->
     decode_element(El, wait_for_handshake, StateData);
 wait_for_handshake(#handshake{data = Digest}, StateData) ->
-    send_element(StateData, #handshake{}),
-    lists:foreach(
-      fun (H) ->
-             ejabberd_router:register_route(H, ?MYNAME),
-             ?INFO_MSG("Route registered for service ~p~n",
-                       [H]),
-             ejabberd_hooks:run(component_connected, [H])
-      end, dict:fetch_keys(StateData#state.host_opts)),
-    {next_state, stream_established, StateData};
-    %% case dict:find(StateData#state.host, StateData#state.host_opts) of
-    %%         {ok, Password} ->
-    %%             case p1_sha:sha(<<(StateData#state.streamid)/binary,
-    %%                               Password/binary>>) of
-    %%                 Digest ->
-    %%                     send_element(StateData, #handshake{}),
-    %%                     lists:foreach(
-    %%                       fun (H) ->
-    %%                               ejabberd_router:register_route(H, ?MYNAME),
-    %%                               ?INFO_MSG("Route registered for service ~p~n",
-    %%                                         [H]),
-    %%                               ejabberd_hooks:run(component_connected, [H])
-    %%                       end, dict:fetch_keys(StateData#state.host_opts)),
-    %%                     {next_state, stream_established, StateData};
-    %%                 _ ->
-    %%                     send_element(StateData, xmpp:serr_not_authorized()),
-    %%                     {stop, normal, StateData}
-    %%             end;
-    %%         _ ->
-    %%             send_element(StateData, xmpp:serr_not_authorized()),
-    %%             {stop, normal, StateData}
-    %% end;
+    case dict:find(StateData#state.host, StateData#state.host_opts) of
+       {ok, Password} ->
+           case p1_sha:sha(<<(StateData#state.streamid)/binary,
+                             Password/binary>>) of
+               Digest ->
+                   send_element(StateData, #handshake{}),
+                   lists:foreach(
+                     fun (H) ->
+                             ejabberd_router:register_route(H, ?MYNAME),
+                             ?INFO_MSG("Route registered for service ~p~n",
+                                       [H]),
+                             ejabberd_hooks:run(component_connected, [H])
+                     end, dict:fetch_keys(StateData#state.host_opts)),
+                   {next_state, stream_established, StateData};
+               _ ->
+                   send_element(StateData, xmpp:serr_not_authorized()),
+                   {stop, normal, StateData}
+           end;
+       _ ->
+           send_element(StateData, xmpp:serr_not_authorized()),
+           {stop, normal, StateData}
+    end;
 wait_for_handshake({xmlstreamend, _Name}, StateData) ->
     {stop, normal, StateData};
 wait_for_handshake({xmlstreamerror, _}, StateData) ->