mirror of
https://github.com/seriyps/mtproto_proxy.git
synced 2026-05-13 16:57:10 +00:00
Accept unexpected RPC packets from Telegram backend
This commit is contained in:
parent
9cb1984889
commit
60d2934bcf
2 changed files with 9 additions and 3 deletions
|
|
@ -286,7 +286,11 @@ handle_rpc({close_ext, ConnId}, St) ->
|
|||
St1
|
||||
end;
|
||||
handle_rpc({simple_ack, ConnId, Confirm}, S) ->
|
||||
up_send({simple_ack, self(), Confirm}, ConnId, S).
|
||||
up_send({simple_ack, self(), Confirm}, ConnId, S);
|
||||
handle_rpc({unknown, Tag, Tail}, S) ->
|
||||
?log(info, "Unknown packet from backend. Tag ~p, tail: ~p", [Tag, Tail]),
|
||||
S.
|
||||
|
||||
|
||||
-spec down_send(iodata(), #state{}) -> {ok, #state{}}.
|
||||
down_send(Packet, #state{sock = Sock, codec = Codec, dc_id = DcId} = St) ->
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ encode_handshake({handshake, SenderPID, PeerPID}) ->
|
|||
|
||||
%% It expects that packet segmentation was done on previous layer
|
||||
%% See mtproto/mtproto-proxy.c:process_client_packet
|
||||
-spec decode_packet(binary()) -> packet() | error.
|
||||
-spec decode_packet(binary()) -> packet() | {unknown, binary(), binary()}.
|
||||
decode_packet(<<?RPC_PROXY_ANS, _AnsFlags:4/binary, ConnId:64/signed-little, Data/binary>>) ->
|
||||
%% mtproto/mtproto-proxy.c:client_send_message
|
||||
{proxy_ans, ConnId, Data};
|
||||
|
|
@ -94,7 +94,9 @@ decode_packet(<<?RPC_CLOSE_EXT, ConnId:64/signed-little>>) ->
|
|||
{close_ext, ConnId};
|
||||
decode_packet(<<?RPC_SIMPLE_ACK, ConnId:64/signed-little, Confirm:4/binary>>) ->
|
||||
%% mtproto/mtproto-proxy.c:push_rpc_confirmation
|
||||
{simple_ack, ConnId, Confirm}.
|
||||
{simple_ack, ConnId, Confirm};
|
||||
decode_packet(<<Tag:4/binary, Tail/binary>>) ->
|
||||
{unknown, Tag, Tail}.
|
||||
|
||||
|
||||
encode_packet({data, Msg}, {{ConnId, ClientAddr, ProxyTag}, ProxyAddr}) ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue