diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cyrsasl_digest.erl | 4 | ||||
-rw-r--r-- | src/cyrsasl_plain.erl | 11 | ||||
-rw-r--r-- | src/ejabberd_c2s.erl | 10 | ||||
-rw-r--r-- | src/ejabberd_http.erl | 4 | ||||
-rw-r--r-- | src/ejabberd_s2s_in.erl | 9 | ||||
-rw-r--r-- | src/ejabberd_service.erl | 9 | ||||
-rw-r--r-- | src/ejabberd_stun.erl | 4 | ||||
-rw-r--r-- | src/ejabberd_xmlrpc.erl | 6 | ||||
-rw-r--r-- | src/mod_muc_room.erl | 2 | ||||
-rw-r--r-- | src/xmpp_stream_in.erl | 28 |
10 files changed, 60 insertions, 27 deletions
diff --git a/src/cyrsasl_digest.erl b/src/cyrsasl_digest.erl index 68fa82ea5..08edf3020 100644 --- a/src/cyrsasl_digest.erl +++ b/src/cyrsasl_digest.erl @@ -59,8 +59,8 @@ start(_Opts) -> Fqdn = get_local_fqdn(), - ?INFO_MSG("FQDN used to check DIGEST-MD5 SASL authentication: ~s", - [Fqdn]), + ?DEBUG("FQDN used to check DIGEST-MD5 SASL authentication: ~s", + [Fqdn]), cyrsasl:register_mechanism(<<"DIGEST-MD5">>, ?MODULE, digest). diff --git a/src/cyrsasl_plain.erl b/src/cyrsasl_plain.erl index ec52b00a8..3bdcf8476 100644 --- a/src/cyrsasl_plain.erl +++ b/src/cyrsasl_plain.erl @@ -81,15 +81,8 @@ prepare(ClientIn) -> _ -> error end. -parse(S) -> parse1(binary_to_list(S), "", []). - -parse1([0 | Cs], S, T) -> - parse1(Cs, "", [list_to_binary(lists:reverse(S)) | T]); -parse1([C | Cs], S, T) -> parse1(Cs, [C | S], T); -%parse1([], [], T) -> -% lists:reverse(T); -parse1([], S, T) -> - lists:reverse([list_to_binary(lists:reverse(S)) | T]). +parse(S) -> + binary:split(S, <<0>>, [global]). parse_domain(S) -> parse_domain1(binary_to_list(S), "", []). diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index a523083c8..4efdafef2 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -999,6 +999,9 @@ opt_type(_) -> (max_stanza_size) -> fun((timeout()) -> timeout()); (max_fsm_queue) -> fun((timeout()) -> timeout()); (stream_management) -> fun((boolean()) -> boolean()); + (inet) -> fun((boolean()) -> boolean()); + (inet6) -> fun((boolean()) -> boolean()); + (backlog) -> fun((timeout()) -> timeout()); (atom()) -> [atom()]. listen_opt_type(access) -> fun acl:access_rules_validator/1; listen_opt_type(shaper) -> fun acl:shaper_rules_validator/1; @@ -1031,13 +1034,18 @@ listen_opt_type(stream_management) -> ?ERROR_MSG("listening option 'stream_management' is ignored: " "use mod_stream_mgmt module", []), fun(B) when is_boolean(B) -> B end; +listen_opt_type(inet) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(inet6) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(backlog) -> + fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(O) -> StreamOpts = mod_stream_mgmt:mod_options(?MYNAME), case lists:keyfind(O, 1, StreamOpts) of false -> [access, shaper, certfile, ciphers, dhfile, cafile, protocol_options, tls, tls_compression, starttls, - starttls_required, tls_verify, zlib, max_fsm_queue]; + starttls_required, tls_verify, zlib, max_fsm_queue, + backlog, inet, inet6]; _ -> ?ERROR_MSG("Listening option '~s' is ignored: use '~s' " "option from mod_stream_mgmt module", [O, O]), diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index 05bdc4495..474304a5d 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -994,6 +994,10 @@ listen_opt_type(default_host) -> fun(A) -> A end; listen_opt_type(custom_headers) -> fun expand_custom_headers/1; +listen_opt_type(inet) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(inet6) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(backlog) -> + fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(_) -> %% TODO fun(A) -> A end. diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 31a936c8c..a02834c78 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -358,6 +358,9 @@ change_shaper(#{shaper := ShaperName, server_host := ServerHost} = State, (supervisor) -> fun((boolean()) -> boolean()); (max_stanza_type) -> fun((timeout()) -> timeout()); (max_fsm_queue) -> fun((pos_integer()) -> pos_integer()); + (inet) -> fun((boolean()) -> boolean()); + (inet6) -> fun((boolean()) -> boolean()); + (backlog) -> fun((timeout()) -> timeout()); (atom()) -> [atom()]. listen_opt_type(shaper) -> fun acl:shaper_rules_validator/1; listen_opt_type(certfile = Opt) -> @@ -381,6 +384,10 @@ listen_opt_type(max_stanza_size) -> end; listen_opt_type(max_fsm_queue) -> fun(I) when is_integer(I), I>0 -> I end; +listen_opt_type(inet) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(inet6) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(backlog) -> + fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(_) -> [shaper, certfile, ciphers, dhfile, cafile, protocol_options, - tls_compression, tls, max_fsm_queue]. + tls_compression, tls, max_fsm_queue, backlog, inet, inet6]. diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 816d643eb..03b768bdf 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -291,6 +291,9 @@ transform_listen_option(Opt, Opts) -> [{binary(), binary() | undefined}]); (max_stanza_type) -> fun((timeout()) -> timeout()); (max_fsm_queue) -> fun((pos_integer()) -> pos_integer()); + (inet) -> fun((boolean()) -> boolean()); + (inet6) -> fun((boolean()) -> boolean()); + (backlog) -> fun((timeout()) -> timeout()); (atom()) -> [atom()]. listen_opt_type(access) -> fun acl:access_rules_validator/1; listen_opt_type(shaper_rule) -> fun acl:shaper_rules_validator/1; @@ -328,7 +331,11 @@ listen_opt_type(max_stanza_size) -> end; listen_opt_type(max_fsm_queue) -> fun(I) when is_integer(I), I>0 -> I end; +listen_opt_type(inet) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(inet6) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(backlog) -> + fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(_) -> [access, shaper_rule, certfile, ciphers, dhfile, cafile, tls, protocol_options, tls_compression, password, hosts, check_from, - max_fsm_queue, global_routes]. + max_fsm_queue, global_routes, backlog, inet, inet6]. diff --git a/src/ejabberd_stun.erl b/src/ejabberd_stun.erl index 342f6302a..adae05f00 100644 --- a/src/ejabberd_stun.erl +++ b/src/ejabberd_stun.erl @@ -172,8 +172,10 @@ listen_opt_type(turn_max_permissions) -> end; listen_opt_type(server_name) -> fun iolist_to_binary/1; +listen_opt_type(backlog) -> + fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(_) -> [shaper, auth_type, auth_realm, tls, certfile, turn_min_port, turn_max_port, turn_max_allocations, turn_max_permissions, - server_name]. + server_name, backlog]. -endif. diff --git a/src/ejabberd_xmlrpc.erl b/src/ejabberd_xmlrpc.erl index 3e0e4fb0b..fb5cbd850 100644 --- a/src/ejabberd_xmlrpc.erl +++ b/src/ejabberd_xmlrpc.erl @@ -581,5 +581,9 @@ listen_opt_type(maxsessions) -> fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(timeout) -> fun(I) when is_integer(I), I>0 -> I end; +listen_opt_type(inet) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(inet6) -> fun(B) when is_boolean(B) -> B end; +listen_opt_type(backlog) -> + fun(I) when is_integer(I), I>0 -> I end; listen_opt_type(_) -> - [access_commands, maxsessions, timeout]. + [access_commands, maxsessions, timeout, backlog, inet, inet6]. diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 87ae28797..35ea746fd 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -3378,6 +3378,8 @@ remove_nonmembers(StateData) -> -spec set_opts([{atom(), any()}], state()) -> state(). set_opts([], StateData) -> StateData; +set_opts([{Opt, Val}, {Opt, _DefaultVal} | Opts], StateData) -> + set_opts([{Opt, Val} | Opts], StateData); set_opts([{Opt, Val} | Opts], StateData) -> NSD = case Opt of title -> diff --git a/src/xmpp_stream_in.erl b/src/xmpp_stream_in.erl index 4f8be911e..55fa3a4bf 100644 --- a/src/xmpp_stream_in.erl +++ b/src/xmpp_stream_in.erl @@ -836,13 +836,13 @@ process_sasl_success(Props, ServerOut, AuthModule = proplists:get_value(auth_module, Props), Socket1 = xmpp_socket:reset_stream(Socket), State0 = State#{socket => Socket1}, - State1 = send_pkt(State0, #sasl_success{text = ServerOut}), + State1 = try Mod:handle_auth_success(User, Mech, AuthModule, State0) + catch _:undef -> State + end, case is_disconnected(State1) of true -> State1; false -> - State2 = try Mod:handle_auth_success(User, Mech, AuthModule, State1) - catch _:undef -> State1 - end, + State2 = send_pkt(State1, #sasl_success{text = ServerOut}), case is_disconnected(State2) of true -> State2; false -> @@ -867,16 +867,22 @@ process_sasl_continue(ServerOut, NewSASLState, State) -> process_sasl_failure(Err, User, #{mod := Mod, sasl_mech := Mech, lang := Lang} = State) -> {Reason, Text} = format_sasl_error(Mech, Err), - State1 = send_pkt(State, #sasl_failure{reason = Reason, - text = xmpp:mk_text(Text, Lang)}), + State1 = try Mod:handle_auth_failure(User, Mech, Text, State) + catch _:undef -> State + end, case is_disconnected(State1) of true -> State1; false -> - State2 = try Mod:handle_auth_failure(User, Mech, Text, State1) - catch _:undef -> State1 - end, - State3 = maps:remove(sasl_state, maps:remove(sasl_mech, State2)), - State3#{stream_state => wait_for_sasl_request} + State2 = send_pkt(State1, + #sasl_failure{reason = Reason, + text = xmpp:mk_text(Text, Lang)}), + case is_disconnected(State2) of + true -> State2; + false -> + State3 = maps:remove(sasl_state, + maps:remove(sasl_mech, State2)), + State3#{stream_state => wait_for_sasl_request} + end end. -spec process_sasl_abort(state()) -> state(). |