Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
er
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
er
Commits
6a9d0377
Unverified
Commit
6a9d0377
authored
Jun 10, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtp_rpc: Fix connection ID (used to be req_id by mistake)
parent
aed27d13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
mtp_rpc.erl
src/mtp_rpc.erl
+9
-8
No files found.
src/mtp_rpc.erl
View file @
6a9d0377
...
...
@@ -18,7 +18,7 @@
{
client_addr
::
binary
(),
proxy_addr
::
binary
(),
proxy_tag
::
binary
(),
req_id
=
1
::
non_neg_integer
()}).
conn_id
::
binary
()}).
-
define
(
APP
,
mtproto_proxy
).
-
define
(
RPC_PROXY_ANS
,
13
,
218
,
3
,
68
).
...
...
@@ -29,10 +29,12 @@
new
(
ClientIp
,
ClientPort
,
ProxyIp
,
ProxyPort
,
ProxyTag
)
->
#rpc_st
{
client_addr
=
iolist_to_binary
(
encode_ip_port
(
ClientIp
,
ClientPort
)),
proxy_addr
=
iolist_to_binary
(
encode_ip_port
(
ProxyIp
,
ProxyPort
)),
proxy_tag
=
ProxyTag
}.
proxy_tag
=
ProxyTag
,
conn_id
=
<<
(
erlang
:
unique_integer
()):
64
/
little
-
signed
>>
}.
%% It expects that packet segmentation was done on previous layer
try_decode_packet
(
<<?
RPC_PROXY_ANS
,
_
AnsFlags
:
4
/
binary
,
_
ReqId
:
8
/
binary
,
Data
/
binary
>>
=
_
Msg
,
S
)
->
try_decode_packet
(
<<?
RPC_PROXY_ANS
,
_
AnsFlags
:
4
/
binary
,
_
ConnId
:
8
/
binary
,
Data
/
binary
>>
=
_
Msg
,
S
)
->
%% TODO: check if we can use downstream multiplexing using ConnId
{
ok
,
Data
,
S
};
try_decode_packet
(
<<?
RPC_CLOSE_EXT
,
_
/
binary
>>
=
_
Msg
,
_
S
)
->
%% Use throw as short-circuit
...
...
@@ -42,15 +44,14 @@ try_decode_packet(<<>>, S) ->
encode_packet
(
Msg
,
#rpc_st
{
client_addr
=
ClientAddr
,
proxy_addr
=
ProxyAddr
,
req_id
=
Req
Id
,
proxy_tag
=
ProxyTag
}
=
S
)
->
conn_id
=
Conn
Id
,
proxy_tag
=
ProxyTag
}
=
S
)
->
((
iolist_size
(
Msg
)
rem
4
)
==
0
)
orelse
error
(
not_aligned
),
Req
=
[
<<
238
,
241
,
206
,
54
,
%RPC_PROXY_REQ
8
,
16
,
2
,
64
,
%Flags
ReqId
:
64
/
little
%ReqId
8
,
16
,
2
,
64
%Flags
>>
,
ClientAddr
,
ProxyAddr
,
C
onnId
,
C
lientAddr
,
ProxyAddr
,
<<
24
:
32
/
little
,
%ExtraSize
174
,
38
,
30
,
219
,
%ProxyTag
(
byte_size
(
ProxyTag
)),
...
...
@@ -59,7 +60,7 @@ encode_packet(Msg, #rpc_st{client_addr = ClientAddr, proxy_addr = ProxyAddr,
>>
|
Msg
],
{
Req
,
S
#rpc_st
{
req_id
=
ReqId
+
1
}
}.
{
Req
,
S
}.
encode_ip_port
(
IPv4
,
Port
)
when
tuple_size
(
IPv4
)
==
4
->
IpBin
=
inet_pton
(
IPv4
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment