mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Support zlib compression after STARTTLS (thanks to Aleksey Shchepin)(EJAB-499)
Unfortunately, zlib compression doesn't work in this branch, neither in this commit or before it. SVN Revision: 2572
This commit is contained in:
parent
98f93104a7
commit
f5eb9e3c9f
@ -769,10 +769,7 @@ password of one of the registered users who are granted access by the
|
||||
‘configure’ access rule.
|
||||
</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>)
|
||||
is available on connections to the port. Client connections cannot use
|
||||
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).
|
||||
is available on connections to the port.
|
||||
</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">
|
||||
<B><TT>{s2s_use_starttls, true|false}</TT></B></DT><DD CLASS="dd-description">
|
||||
|
@ -905,10 +905,7 @@ This is a detailed description of each option allowed by the listening modules:
|
||||
`configure' access rule.
|
||||
\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})
|
||||
is available on connections to the port. Client connections cannot use
|
||||
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).
|
||||
is available on connections to the port.
|
||||
\end{description}
|
||||
|
||||
There are some additional global options that can be specified in the ejabberd configuration file (outside \term{listen}):
|
||||
|
@ -274,7 +274,8 @@ wait_for_stream({xmlstreamstart, #xmlel{ns = NS} = Opening}, StateData) ->
|
||||
Zlib = StateData#state.zlib,
|
||||
CompressFeature =
|
||||
case Zlib andalso
|
||||
(SockMod == gen_tcp) of
|
||||
((SockMod == gen_tcp) orelse
|
||||
(SockMod == tls)) of
|
||||
true ->
|
||||
[exmpp_server_compression:feature(["zlib"])];
|
||||
_ ->
|
||||
@ -578,13 +579,14 @@ wait_for_feature_request({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
|
||||
tls_enabled = true
|
||||
});
|
||||
{?NS_COMPRESS, 'compress'} when Zlib == true,
|
||||
SockMod == gen_tcp ->
|
||||
((SockMod == gen_tcp) or
|
||||
(SockMod == tls)) ->
|
||||
case exmpp_server_compression:selected_method(El) of
|
||||
undefined ->
|
||||
send_element(StateData,
|
||||
exmpp_server_compression:failure('steup-failed')),
|
||||
exmpp_server_compression:failure('setup-failed')),
|
||||
fsm_next_state(wait_for_feature_request, StateData);
|
||||
"zlib" ->
|
||||
<<"zlib">> ->
|
||||
Socket = StateData#state.socket,
|
||||
ZlibSocket = (StateData#state.sockmod):compress(
|
||||
Socket,
|
||||
@ -1332,11 +1334,18 @@ get_auth_tags([_ | L], U, P, D, R) ->
|
||||
get_auth_tags([], U, P, D, R) ->
|
||||
{U, P, D, R}.
|
||||
|
||||
%% Copied from ejabberd_socket.erl
|
||||
-record(socket_state, {sockmod, socket, receiver}).
|
||||
|
||||
get_conn_type(StateData) ->
|
||||
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
|
||||
gen_tcp -> c2s;
|
||||
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_bind -> http_bind;
|
||||
_ -> unknown
|
||||
|
@ -35,6 +35,7 @@
|
||||
recv/2, recv/3, recv_data/2,
|
||||
setopts/2,
|
||||
sockname/1, peername/1,
|
||||
get_sockmod/1,
|
||||
controlling_process/2,
|
||||
close/1]).
|
||||
|
||||
@ -116,7 +117,20 @@ recv(#zlibsock{sockmod = SockMod, socket = Socket} = ZlibSock,
|
||||
Error
|
||||
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
|
||||
{'EXIT', Reason} ->
|
||||
{error, Reason};
|
||||
@ -158,6 +172,9 @@ sockname(#zlibsock{sockmod = SockMod, socket = Socket}) ->
|
||||
SockMod:sockname(Socket)
|
||||
end.
|
||||
|
||||
get_sockmod(#zlibsock{sockmod = SockMod}) ->
|
||||
SockMod.
|
||||
|
||||
peername(#zlibsock{sockmod = SockMod, socket = Socket}) ->
|
||||
case SockMod of
|
||||
gen_tcp ->
|
||||
|
@ -1696,6 +1696,7 @@ user_info(User, Server, Query, Lang) ->
|
||||
c2s -> "plain";
|
||||
c2s_tls -> "tls";
|
||||
c2s_compressed -> "zlib";
|
||||
c2s_compressed_tls -> "tls+zlib";
|
||||
http_bind -> "http-bind";
|
||||
http_poll -> "http-poll"
|
||||
end,
|
||||
|
Loading…
Reference in New Issue
Block a user