diff options
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | ejabberd.yml.example | 4 | ||||
-rw-r--r-- | mix.exs | 6 | ||||
-rw-r--r-- | mix.lock | 15 | ||||
-rw-r--r-- | rebar.config | 4 | ||||
-rw-r--r-- | rebar.config.script | 2 | ||||
-rw-r--r-- | src/ejabberd_app.erl | 6 | ||||
-rw-r--r-- | src/mod_http_fileserver.erl | 38 | ||||
-rw-r--r-- | src/mod_muc.erl | 4 | ||||
-rw-r--r-- | src/mod_muc_admin.erl | 2 | ||||
-rw-r--r-- | src/mod_muc_room.erl | 8 | ||||
-rw-r--r-- | src/mod_offline.erl | 2 | ||||
-rw-r--r-- | src/mod_pubsub.erl | 8 | ||||
-rw-r--r-- | src/translate.erl | 4 | ||||
-rw-r--r-- | src/xmpp_stream_out.erl | 6 |
15 files changed, 70 insertions, 41 deletions
diff --git a/Makefile.in b/Makefile.in index 28c04227f..a0b4553dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -295,7 +295,7 @@ dialyzer/erlang.plt: @mkdir -p dialyzer @dialyzer --build_plt --output_plt dialyzer/erlang.plt \ -o dialyzer/erlang.log --apps kernel stdlib sasl crypto \ - public_key ssl mnesia inets odbc tools compiler erts webtool \ + public_key ssl mnesia inets odbc tools compiler erts \ runtime_tools asn1 observer xmerl et gs wx syntax_tools; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi diff --git a/ejabberd.yml.example b/ejabberd.yml.example index 2fd754d63..fe9b5083d 100644 --- a/ejabberd.yml.example +++ b/ejabberd.yml.example @@ -192,7 +192,7 @@ listen: ###' S2S GLOBAL OPTIONS ## -## s2s_use_starttls: Enable STARTTLS + Dialback for S2S connections. +## s2s_use_starttls: Enable STARTTLS for S2S connections. ## Allowed values are: false optional required required_trusted ## You must specify a certificate file. ## @@ -628,7 +628,7 @@ modules: mod_disco: {} ## mod_echo: {} mod_irc: {} - mod_http_bind: {} + mod_bosh: {} ## mod_http_fileserver: ## docroot: "/var/www" ## accesslog: "/var/log/ejabberd/access.log" @@ -40,13 +40,13 @@ defmodule Ejabberd.Mixfile do defp deps do [{:lager, "~> 3.2"}, - {:p1_utils, "~> 1.0"}, + {:p1_utils, github: "processone/p1_utils", tag: "1.0.7", override: true}, + {:fast_xml, github: "processone/fast_xml", tag: "1.1.22", override: true, manager: :rebar}, + {:xmpp, github: "processone/xmpp", tag: "1.1.9", manager: :rebar}, {:cache_tab, "~> 1.0"}, {:stringprep, "~> 1.0"}, {:fast_yaml, "~> 1.0"}, {:fast_tls, "~> 1.0"}, - {:fast_xml, "~> 1.1"}, - {:xmpp, "~> 1.1"}, {:stun, "~> 1.0"}, {:esip, "~> 1.0"}, {:jiffy, "~> 0.14.7"}, @@ -1,12 +1,13 @@ %{"cache_tab": {:hex, :cache_tab, "1.0.6", "d76643e614f310347b0a539543751f5ad950b0aecdabf7c82e2e1b901ef29df4", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, - "distillery": {:hex, :distillery, "1.1.0", "e9943bd29557e9c252a051d8ac4b47e597cd9bf2a74332b8628eab4954eb51d7", [:mix], []}, - "earmark": {:hex, :earmark, "1.1.0", "8c2bf85d725050a92042bc1edf362621004d43ca6241c756f39612084e95487f", [:mix], []}, + "distillery": {:hex, :distillery, "1.2.2", "d5a52920cbe2378c8a21dfc83b526b4225944b9dce7bf170fe5f5cddda81ffb3", [:mix], []}, + "earmark": {:hex, :earmark, "1.2.0", "bf1ce17aea43ab62f6943b97bd6e3dc032ce45d4f787504e3adf738e54b42f3a", [:mix], []}, + "elixir_make": {:hex, :elixir_make, "0.4.0", "992f38fabe705bb45821a728f20914c554b276838433349d4f2341f7a687cddf", [:mix], []}, "eredis": {:hex, :eredis, "1.0.8", "ab4fda1c4ba7fbe6c19c26c249dc13da916d762502c4b4fa2df401a8d51c5364", [:rebar], []}, "esip": {:hex, :esip, "1.0.10", "473856746df3136bce62973db8270c6811a366c7ce21c6139f725e29b359ef8e", [:rebar3], [{:fast_tls, "1.0.10", [hex: :fast_tls, optional: false]}, {:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}, {:stun, "1.0.9", [hex: :stun, optional: false]}]}, - "ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, + "ex_doc": {:hex, :ex_doc, "0.15.0", "e73333785eef3488cf9144a6e847d3d647e67d02bd6fdac500687854dd5c599f", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]}, "ezlib": {:hex, :ezlib, "1.0.2", "22004ecf553a7d831404394d5642712e2aede90522e22bd6ccc089ca410ee098", [:rebar3], []}, "fast_tls": {:hex, :fast_tls, "1.0.10", "d403f20978ec30814203191b33764c016a49c0fce09fc0540eb56c087d5167de", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, - "fast_xml": {:hex, :fast_xml, "1.1.19", "7400b1c879941a52a62b97a370419ed7a1d448356bad000d5a80cda3f0b8a60d", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, + "fast_xml": {:git, "https://github.com/processone/fast_xml.git", "984933e581dd4091f775f3b59dd76bfddfa8097e", [tag: "1.1.22"]}, "fast_yaml": {:hex, :fast_yaml, "1.0.8", "1b7438f1ecc3822b57c0aaa26d8f3ee93725fb89f7cc5a204a77339cac92dd93", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, "goldrush": {:hex, :goldrush, "0.1.9", "f06e5d5f1277da5c413e84d5a2924174182fb108dabb39d5ec548b27424cd106", [:rebar3], []}, "iconv": {:hex, :iconv, "1.0.3", "f5c159f7e0ad2a3b55c6b5528ce71d7926f206df2f9bf83201a77cf1bc91c6f0", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, @@ -14,7 +15,9 @@ "lager": {:hex, :lager, "3.2.4", "a6deb74dae7927f46bd13255268308ef03eb206ec784a94eaf7c1c0f3b811615", [:rebar3], [{:goldrush, "0.1.9", [hex: :goldrush, optional: false]}]}, "p1_mysql": {:hex, :p1_mysql, "1.0.2", "893a99415f98ce8b6ad014ef950d4e878895787b6c8333587f1e506f831571e0", [:rebar3], []}, "p1_oauth2": {:hex, :p1_oauth2, "0.6.1", "4e021250cc198c538b097393671a41e7cebf463c248980320e038fe0316eb56b", [:rebar3], []}, - "p1_utils": {:hex, :p1_utils, "1.0.6", "ef0951ddf38e92b7e479af4b8dc950df76af8c1030432ef68b7fd7ad17c436fe", [:rebar3], []}, + "p1_pgsql": {:hex, :p1_pgsql, "1.1.2", "27d3137e0b0098808d9c60bf197344669ed1107ed47ce4af2254099a62ccc27e", [:rebar3], []}, + "p1_utils": {:git, "https://github.com/processone/p1_utils.git", "0860e5f913ccf6ded432450c942927cca5ccdbea", [tag: "1.0.7"]}, + "sqlite3": {:hex, :sqlite3, "1.1.5", "794738b6d07b6d36ec6d42492cb9d629bad9cf3761617b8b8d728e765db19840", [:rebar3], []}, "stringprep": {:hex, :stringprep, "1.0.7", "f709c7ee3697ae9d2becbbbba1dcea47e0f583e313b4eb7d0ced2163c595ee12", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, "stun": {:hex, :stun, "1.0.9", "daf2db395ac69d9808f13c208f26eda75b83e43d7083d4dd8dda28c63d900672", [:rebar3], [{:fast_tls, "1.0.10", [hex: :fast_tls, optional: false]}, {:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, - "xmpp": {:hex, :xmpp, "1.1.6", "0b43cc5fd61de06654bbc74e41faa94ca74ebb3fec7ca4ba684318bb105e912a", [:rebar3], [{:fast_xml, "1.1.19", [hex: :fast_xml, optional: false]}, {:stringprep, "1.0.7", [hex: :stringprep, optional: false]}]}} + "xmpp": {:git, "https://github.com/processone/xmpp.git", "2d40be0964eebd30b729b1bc20fe309884a20186", [tag: "1.1.9"]}} diff --git a/rebar.config b/rebar.config index f38591955..e80fe3131 100644 --- a/rebar.config +++ b/rebar.config @@ -21,10 +21,10 @@ {deps, [{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.2.1"}}}, {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.7"}}}, {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.6"}}}, - {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", "afdd07811e0e6eff444c035ffeb2aa9efb4dbe6d"}}, + {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.11"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}}, {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}}, - {xmpp, ".*", {git, "https://github.com/processone/xmpp", "4aaed37a16fc21be505553aabf9f47a48b8af027"}}, + {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.1.9"}}}, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.9"}}}, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}}, {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}}, diff --git a/rebar.config.script b/rebar.config.script index 0ca424116..19142b9ee 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -18,7 +18,7 @@ %%% %%%---------------------------------------------------------------------- -Vars = case file:consult("vars.config") of +Vars = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"])) of {ok, Terms} -> Terms; _Err -> diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index f4d10e5a5..a2fc8adcb 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -40,6 +40,7 @@ %%% start(normal, _Args) -> + {T1, _} = statistics(wall_clock), ejabberd_logger:start(), write_pid_file(), start_apps(), @@ -54,8 +55,9 @@ start(normal, _Args) -> case ejabberd_sup:start_link() of {ok, SupPid} -> register_elixir_config_hooks(), - ?INFO_MSG("ejabberd ~s is started in the node ~p", - [?VERSION, node()]), + {T2, _} = statistics(wall_clock), + ?INFO_MSG("ejabberd ~s is started in the node ~p in ~.2fs", + [?VERSION, node(), (T2-T1)/1000]), {ok, SupPid}; Err -> Err diff --git a/src/mod_http_fileserver.erl b/src/mod_http_fileserver.erl index 27c4800f7..4aa47902a 100644 --- a/src/mod_http_fileserver.erl +++ b/src/mod_http_fileserver.erl @@ -230,11 +230,17 @@ try_open_log(FN, _Host) -> %% {stop, Reason, State} %% Description: Handling call messages %%-------------------------------------------------------------------- -handle_call({serve, LocalPath, Auth}, _From, State) -> +handle_call({serve, LocalPath, Auth, RHeaders}, _From, State) -> + IfModifiedSince = case find_header('If-Modified-Since', RHeaders, bad_date) of + bad_date -> + bad_date; + Val -> + httpd_util:convert_request_date(binary_to_list(Val)) + end, Reply = serve(LocalPath, Auth, State#state.docroot, State#state.directory_indices, State#state.custom_headers, State#state.default_content_type, State#state.content_types, - State#state.user_access), + State#state.user_access, IfModifiedSince), {reply, Reply, State}; handle_call(_Request, _From, State) -> {reply, ok, State}. @@ -300,9 +306,9 @@ code_change(_OldVsn, State, _Extra) -> %% @doc Handle an HTTP request. %% LocalPath is the part of the requested URL path that is "local to the module". %% Returns the page to be sent back to the client and/or HTTP status code. -process(LocalPath, #request{host = Host, auth = Auth} = Request) -> +process(LocalPath, #request{host = Host, auth = Auth, headers = RHeaders} = Request) -> ?DEBUG("Requested ~p", [LocalPath]), - try gen_server:call(get_proc_name(Host), {serve, LocalPath, Auth}) of + try gen_server:call(get_proc_name(Host), {serve, LocalPath, Auth, RHeaders}) of {FileSize, Code, Headers, Contents} -> add_to_log(FileSize, Code, Request), {Code, Headers, Contents} @@ -315,7 +321,7 @@ process(LocalPath, #request{host = Host, auth = Auth} = Request) -> serve(LocalPath, Auth, DocRoot, DirectoryIndices, CustomHeaders, DefaultContentType, - ContentTypes, UserAccess) -> + ContentTypes, UserAccess, IfModifiedSince) -> CanProceed = case {UserAccess, Auth} of {none, _} -> true; {_, {User, Pass}} -> @@ -338,10 +344,17 @@ serve(LocalPath, Auth, DocRoot, DirectoryIndices, CustomHeaders, DefaultContentT CustomHeaders, DefaultContentType, ContentTypes); - {ok, FileInfo} -> serve_file(FileInfo, FileName, - CustomHeaders, - DefaultContentType, - ContentTypes) + {ok, #file_info{mtime = MTime} = FileInfo} -> + case calendar:local_time_to_universal_time_dst(MTime) of + [IfModifiedSince | _] -> + serve_not_modified(FileInfo, FileName, + CustomHeaders); + _ -> + serve_file(FileInfo, FileName, + CustomHeaders, + DefaultContentType, + ContentTypes) + end end; _ -> ?HTTP_ERR_FORBIDDEN @@ -359,6 +372,13 @@ serve_index(FileName, [Index | T], CH, DefaultContentType, ContentTypes) -> {ok, FileInfo} -> serve_file(FileInfo, IndexFileName, CH, DefaultContentType, ContentTypes) end. +serve_not_modified(FileInfo, FileName, CustomHeaders) -> + ?DEBUG("Delivering not modified: ~s", [FileName]), + {0, 304, + [{<<"Server">>, <<"ejabberd">>}, + {<<"Last-Modified">>, last_modified(FileInfo)} + | CustomHeaders], <<>>}. + %% Assume the file exists if we got this far and attempt to read it in %% and serve it up. serve_file(FileInfo, FileName, CustomHeaders, DefaultContentType, ContentTypes) -> diff --git a/src/mod_muc.erl b/src/mod_muc.erl index f9488cf9a..65e61694f 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -772,9 +772,7 @@ iq_get_register_info(ServerHost, Host, From, Lang) -> Title = <<(translate:translate( Lang, <<"Nickname Registration at ">>))/binary, Host/binary>>, Inst = translate:translate(Lang, <<"Enter nickname you want to register">>), - Fields = muc_register:encode( - [{roomnick, Nick}], - fun(T) -> translate:translate(Lang, T) end), + Fields = muc_register:encode([{roomnick, Nick}], Lang), X = #xdata{type = form, title = Title, instructions = [Inst], fields = Fields}, #register{nick = Nick, diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 4b1509fc9..6b1fcb941 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -484,7 +484,7 @@ create_room_with_opts(Name1, Host1, ServerHost, CustomRoomOpts) -> HistorySize, RoomShaper, RoomOpts), - mod_muc:register_online_room(Host, Name, Pid), + mod_muc:register_online_room(Name, Host, Pid), ok; {ok, _} -> error diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 8ab14a92b..dc30cc898 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -3198,8 +3198,7 @@ get_config(Lang, StateData, From) -> Fs, [StateData, From, Lang]), #xdata{type = form, title = Title, - fields = muc_roomconfig:encode( - Fields, fun(T) -> translate:translate(Lang, T) end)}. + fields = muc_roomconfig:encode(Fields, Lang)}. -spec set_config(muc_roomconfig:result(), state(), binary()) -> {error, stanza_error()} | {result, undefined, state()}. @@ -3613,8 +3612,7 @@ iq_disco_info_extras(Lang, StateData) -> Fs = [{description, (StateData#state.config)#config.description}, {occupants, ?DICT:size(StateData#state.users)}], #xdata{type = result, - fields = muc_roominfo:encode( - Fs, fun(T) -> translate:translate(Lang, T) end)}. + fields = muc_roominfo:encode(Fs, Lang)}. -spec process_iq_disco_items(jid(), iq(), state()) -> {error, stanza_error()} | {result, disco_items()}. @@ -3835,7 +3833,7 @@ prepare_request_form(Requester, Nick, Lang) -> {jid, Requester}, {roomnick, Nick}, {request_allow, false}], - fun(T) -> translate:translate(Lang, T) end), + Lang), #message{type = normal, sub_els = [#xdata{type = form, title = Title, diff --git a/src/mod_offline.erl b/src/mod_offline.erl index ba304f821..db2efb040 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -319,7 +319,7 @@ get_info(_Acc, #jid{luser = U, lserver = S} = JID, [#xdata{type = result, fields = flex_offline:encode( [{number_of_messages, count_offline_messages(U, S)}], - fun(T) -> translate:translate(Lang, T) end)}]; + Lang)}]; get_info(Acc, _From, _To, _Node, _Lang) -> Acc. diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 4ea840011..a0ac8643e 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -1371,7 +1371,7 @@ adhoc_request(_Host, _ServerHost, _Owner, Other, _Access, _Plugins) -> -spec send_pending_node_form(binary(), jid(), binary(), [binary()]) -> adhoc_command() | {error, stanza_error()}. -send_pending_node_form(Host, Owner, _Lang, Plugins) -> +send_pending_node_form(Host, Owner, Lang, Plugins) -> Filter = fun (Type) -> lists:member(<<"get-pending">>, plugin_features(Host, Type)) end, @@ -1385,7 +1385,7 @@ send_pending_node_form(Host, Owner, _Lang, Plugins) -> {ok, Nodes} -> XForm = #xdata{type = form, fields = pubsub_get_pending:encode( - [{node, Nodes}])}, + [{node, Nodes}], Lang)}, #adhoc_command{status = executing, action = execute, xdata = XForm}; Err -> @@ -1454,7 +1454,7 @@ send_authorization_request(#pubsub_node{nodeid = {Host, Node}, [{node, Node}, {subscriber_jid, Subscriber}, {allow, false}], - fun(T) -> translate:translate(Lang, T) end), + Lang), X = #xdata{type = form, title = translate:translate( Lang, <<"PubSub subscriber request">>), @@ -3281,7 +3281,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) -> (Opt) -> Opt end, Options), - fun(Txt) -> translate:translate(Lang, Txt) end). + Lang). %%<p>There are several reasons why the node configuration request might fail:</p> %%<ul> diff --git a/src/translate.erl b/src/translate.erl index 4350fab27..cf59fef5b 100644 --- a/src/translate.erl +++ b/src/translate.erl @@ -43,6 +43,7 @@ start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). init([]) -> + process_flag(trap_exit, true), ets:new(translations, [named_table, public]), Dir = case os:getenv("EJABBERD_MSGS_PATH") of false -> @@ -53,6 +54,7 @@ init([]) -> Path -> Path end, load_dir(iolist_to_binary(Dir)), + xmpp:set_tr_callback({?MODULE, translate}), {ok, #state{}}. handle_call(_Request, _From, State) -> @@ -66,7 +68,7 @@ handle_info(_Info, State) -> {noreply, State}. terminate(_Reason, _State) -> - ok. + xmpp:set_tr_callback(undefined). code_change(_OldVsn, State, _Extra) -> {ok, State}. diff --git a/src/xmpp_stream_out.erl b/src/xmpp_stream_out.erl index 3832a75d6..d0a39158d 100644 --- a/src/xmpp_stream_out.erl +++ b/src/xmpp_stream_out.erl @@ -518,12 +518,18 @@ process_features(#stream_features{sub_els = Els} = StreamFeatures, false when TLSRequired and not Encrypted -> Txt = <<"Use of STARTTLS required">>, send_pkt(State1, xmpp:serr_policy_violation(Txt, Lang)); + false when not Encrypted -> + process_sasl_failure( + <<"Peer doesn't support STARTTLS">>, State1); #starttls{required = true} when not TLSAvailable and not Encrypted -> Txt = <<"Use of STARTTLS forbidden">>, send_pkt(State1, xmpp:serr_unsupported_feature(Txt, Lang)); #starttls{} when TLSAvailable and not Encrypted -> State2 = State1#{stream_state => wait_for_starttls_response}, send_pkt(State2, #starttls{}); + #starttls{} when not Encrypted -> + process_sasl_failure( + <<"STARTTLS is disabled in local configuration">>, State1); _ -> State2 = process_cert_verification(State1), case is_disconnected(State2) of |