mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-16 22:05:29 +02:00
Support zlib compression after STARTTLS (thanks to Aleksey Shchepin)(EJAB-499)
SVN Revision: 2571
This commit is contained in:
parent
a5c5808911
commit
fd57ec5872
|
@ -779,10 +779,7 @@ password of one of the registered users who are granted access by the
|
||||||
‘configure’ access rule.
|
‘configure’ access rule.
|
||||||
</DD><DT CLASS="dt-description"><B><TT>zlib</TT></B></DT><DD CLASS="dd-description"> This
|
</DD><DT CLASS="dt-description"><B><TT>zlib</TT></B></DT><DD CLASS="dd-description"> This
|
||||||
option specifies that Zlib stream compression (as defined in <A HREF="http://xmpp.org/extensions/xep-0138.html">XEP-0138</A>)
|
option specifies that Zlib stream compression (as defined in <A HREF="http://xmpp.org/extensions/xep-0138.html">XEP-0138</A>)
|
||||||
is available on connections to the port. Client connections cannot use
|
is available on connections to the port.
|
||||||
stream compression and stream encryption simultaneously. Hence, if you
|
|
||||||
specify both <TT>starttls</TT> (or <TT>tls</TT>) and <TT>zlib</TT>, the latter
|
|
||||||
option will not affect connections (there will be no stream compression).
|
|
||||||
</DD></DL><P>There are some additional global options that can be specified in the ejabberd configuration file (outside <TT>listen</TT>):
|
</DD></DL><P>There are some additional global options that can be specified in the ejabberd configuration file (outside <TT>listen</TT>):
|
||||||
</P><DL CLASS="description"><DT CLASS="dt-description">
|
</P><DL CLASS="description"><DT CLASS="dt-description">
|
||||||
<B><TT>{s2s_use_starttls, true|false}</TT></B></DT><DD CLASS="dd-description">
|
<B><TT>{s2s_use_starttls, true|false}</TT></B></DT><DD CLASS="dd-description">
|
||||||
|
|
|
@ -920,10 +920,7 @@ This is a detailed description of each option allowed by the listening modules:
|
||||||
`configure' access rule.
|
`configure' access rule.
|
||||||
\titem{zlib} \ind{options!zlib}\ind{protocols!XEP-0138: Stream Compression}\ind{Zlib}This
|
\titem{zlib} \ind{options!zlib}\ind{protocols!XEP-0138: Stream Compression}\ind{Zlib}This
|
||||||
option specifies that Zlib stream compression (as defined in \xepref{0138})
|
option specifies that Zlib stream compression (as defined in \xepref{0138})
|
||||||
is available on connections to the port. Client connections cannot use
|
is available on connections to the port.
|
||||||
stream compression and stream encryption simultaneously. Hence, if you
|
|
||||||
specify both \option{starttls} (or \option{tls}) and \option{zlib}, the latter
|
|
||||||
option will not affect connections (there will be no stream compression).
|
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
There are some additional global options that can be specified in the ejabberd configuration file (outside \term{listen}):
|
There are some additional global options that can be specified in the ejabberd configuration file (outside \term{listen}):
|
||||||
|
|
|
@ -278,7 +278,8 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||||
Zlib = StateData#state.zlib,
|
Zlib = StateData#state.zlib,
|
||||||
CompressFeature =
|
CompressFeature =
|
||||||
case Zlib andalso
|
case Zlib andalso
|
||||||
(SockMod == gen_tcp) of
|
((SockMod == gen_tcp) orelse
|
||||||
|
(SockMod == tls)) of
|
||||||
true ->
|
true ->
|
||||||
[{xmlelement, "compression",
|
[{xmlelement, "compression",
|
||||||
[{"xmlns", ?NS_FEATURE_COMPRESS}],
|
[{"xmlns", ?NS_FEATURE_COMPRESS}],
|
||||||
|
@ -628,7 +629,8 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
|
||||||
tls_enabled = true
|
tls_enabled = true
|
||||||
});
|
});
|
||||||
{?NS_COMPRESS, "compress"} when Zlib == true,
|
{?NS_COMPRESS, "compress"} when Zlib == true,
|
||||||
SockMod == gen_tcp ->
|
((SockMod == gen_tcp) or
|
||||||
|
(SockMod == tls)) ->
|
||||||
case xml:get_subtag(El, "method") of
|
case xml:get_subtag(El, "method") of
|
||||||
false ->
|
false ->
|
||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
|
@ -1415,11 +1417,18 @@ get_auth_tags([_ | L], U, P, D, R) ->
|
||||||
get_auth_tags([], U, P, D, R) ->
|
get_auth_tags([], U, P, D, R) ->
|
||||||
{U, P, D, R}.
|
{U, P, D, R}.
|
||||||
|
|
||||||
|
%% Copied from ejabberd_socket.erl
|
||||||
|
-record(socket_state, {sockmod, socket, receiver}).
|
||||||
|
|
||||||
get_conn_type(StateData) ->
|
get_conn_type(StateData) ->
|
||||||
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
|
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
|
||||||
gen_tcp -> c2s;
|
gen_tcp -> c2s;
|
||||||
tls -> c2s_tls;
|
tls -> c2s_tls;
|
||||||
ejabberd_zlib -> c2s_compressed;
|
ejabberd_zlib ->
|
||||||
|
case ejabberd_zlib:get_sockmod((StateData#state.socket)#socket_state.socket) of
|
||||||
|
gen_tcp -> c2s_compressed;
|
||||||
|
tls -> c2s_compressed_tls
|
||||||
|
end;
|
||||||
ejabberd_http_poll -> http_poll;
|
ejabberd_http_poll -> http_poll;
|
||||||
ejabberd_http_bind -> http_bind;
|
ejabberd_http_bind -> http_bind;
|
||||||
_ -> unknown
|
_ -> unknown
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
recv/2, recv/3, recv_data/2,
|
recv/2, recv/3, recv_data/2,
|
||||||
setopts/2,
|
setopts/2,
|
||||||
sockname/1, peername/1,
|
sockname/1, peername/1,
|
||||||
|
get_sockmod/1,
|
||||||
controlling_process/2,
|
controlling_process/2,
|
||||||
close/1]).
|
close/1]).
|
||||||
|
|
||||||
|
@ -116,7 +117,20 @@ recv(#zlibsock{sockmod = SockMod, socket = Socket} = ZlibSock,
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
recv_data(ZlibSock, Packet) ->
|
recv_data(#zlibsock{sockmod = SockMod, socket = Socket} = ZlibSock, Packet) ->
|
||||||
|
case SockMod of
|
||||||
|
gen_tcp ->
|
||||||
|
recv_data2(ZlibSock, Packet);
|
||||||
|
_ ->
|
||||||
|
case SockMod:recv_data(Socket, Packet) of
|
||||||
|
{ok, Packet2} ->
|
||||||
|
recv_data2(ZlibSock, Packet2);
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
|
recv_data2(ZlibSock, Packet) ->
|
||||||
case catch recv_data1(ZlibSock, Packet) of
|
case catch recv_data1(ZlibSock, Packet) of
|
||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
|
@ -158,6 +172,9 @@ sockname(#zlibsock{sockmod = SockMod, socket = Socket}) ->
|
||||||
SockMod:sockname(Socket)
|
SockMod:sockname(Socket)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
get_sockmod(#zlibsock{sockmod = SockMod}) ->
|
||||||
|
SockMod.
|
||||||
|
|
||||||
peername(#zlibsock{sockmod = SockMod, socket = Socket}) ->
|
peername(#zlibsock{sockmod = SockMod, socket = Socket}) ->
|
||||||
case SockMod of
|
case SockMod of
|
||||||
gen_tcp ->
|
gen_tcp ->
|
||||||
|
|
|
@ -1663,6 +1663,7 @@ user_info(User, Server, Query, Lang) ->
|
||||||
c2s -> "plain";
|
c2s -> "plain";
|
||||||
c2s_tls -> "tls";
|
c2s_tls -> "tls";
|
||||||
c2s_compressed -> "zlib";
|
c2s_compressed -> "zlib";
|
||||||
|
c2s_compressed_tls -> "tls+zlib";
|
||||||
http_bind -> "http-bind";
|
http_bind -> "http-bind";
|
||||||
http_poll -> "http-poll"
|
http_poll -> "http-poll"
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user