Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtproto_proxy
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
mtproto_proxy
Commits
b0f6ee29
Unverified
Commit
b0f6ee29
authored
Oct 17, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rpc_close_ext
parent
a182c3be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
13 deletions
+34
-13
mtp_down_conn.erl
src/mtp_down_conn.erl
+28
-9
mtp_handler.erl
src/mtp_handler.erl
+6
-4
No files found.
src/mtp_down_conn.erl
View file @
b0f6ee29
...
@@ -145,6 +145,7 @@ handle_upstream_new(Upstream, Opts, #state{upstreams = Ups,
...
@@ -145,6 +145,7 @@ handle_upstream_new(Upstream, Opts, #state{upstreams = Ups,
%% Upstream process is exited (or about to exit)
%% Upstream process is exited (or about to exit)
handle_upstream_closed
(
Upstream
,
#state
{
upstreams
=
Ups
,
handle_upstream_closed
(
Upstream
,
#state
{
upstreams
=
Ups
,
upstreams_rev
=
UpsRev
}
=
St
)
->
upstreams_rev
=
UpsRev
}
=
St
)
->
%% See "mtproto-proxy.c:remove_ext_connection
case
maps
:
take
(
Upstream
,
Ups
)
of
case
maps
:
take
(
Upstream
,
Ups
)
of
{{
ConnId
,
_,
_},
Ups1
}
->
{{
ConnId
,
_,
_},
Ups1
}
->
UpsRev1
=
maps
:
remove
(
ConnId
,
UpsRev
),
UpsRev1
=
maps
:
remove
(
ConnId
,
UpsRev
),
...
@@ -153,7 +154,8 @@ handle_upstream_closed(Upstream, #state{upstreams = Ups,
...
@@ -153,7 +154,8 @@ handle_upstream_closed(Upstream, #state{upstreams = Ups,
Packet
=
mtp_rpc
:
encode_packet
(
remote_closed
,
ConnId
),
Packet
=
mtp_rpc
:
encode_packet
(
remote_closed
,
ConnId
),
down_send
(
Packet
,
St1
);
down_send
(
Packet
,
St1
);
error
->
error
->
lager
:
warning
(
"Unknown upstream
~p
"
,
[
Upstream
]),
%% It happens when we get rpc_close_ext
lager
:
info
(
"Unknown upstream
~p
"
,
[
Upstream
]),
{
ok
,
St
}
{
ok
,
St
}
end
.
end
.
...
@@ -190,10 +192,21 @@ handle_downstream_data(Bin, #state{stage = handshake_2,
...
@@ -190,10 +192,21 @@ handle_downstream_data(Bin, #state{stage = handshake_2,
end
.
end
.
-
spec
handle_rpc
(
mtp_rpc
:
packet
(),
#state
{})
->
#state
{}.
-
spec
handle_rpc
(
mtp_rpc
:
packet
(),
#state
{})
->
#state
{}.
handle_rpc
({
proxy_ans
,
ConnId
,
Data
},
S
)
->
handle_rpc
({
proxy_ans
,
ConnId
,
Data
},
St
)
->
up_send
({
proxy_ans
,
self
(),
Data
},
ConnId
,
S
);
up_send
({
proxy_ans
,
self
(),
Data
},
ConnId
,
St
);
handle_rpc
({
close_ext
,
ConnId
},
S
)
->
handle_rpc
({
close_ext
,
ConnId
},
St
)
->
up_send
({
close_ext
,
self
()},
ConnId
,
S
);
#state
{
upstreams
=
Ups
,
upstreams_rev
=
UpsRev
}
=
St1
=
up_send
({
close_ext
,
self
()},
ConnId
,
St
),
case
maps
:
take
(
ConnId
,
UpsRev
)
of
{
Upstream
,
UpsRev1
}
->
Ups1
=
maps
:
remove
(
Upstream
,
Ups
),
St2
=
St1
#state
{
upstreams
=
Ups1
,
upstreams_rev
=
UpsRev1
},
St2
;
error
->
lager
:
warning
(
"Unknown upstream
~p
"
,
[
ConnId
]),
St1
end
;
handle_rpc
({
simple_ack
,
ConnId
,
Confirm
},
S
)
->
handle_rpc
({
simple_ack
,
ConnId
,
Confirm
},
S
)
->
up_send
({
simple_ack
,
self
(),
Confirm
},
ConnId
,
S
).
up_send
({
simple_ack
,
self
(),
Confirm
},
ConnId
,
S
).
...
@@ -210,10 +223,16 @@ down_send(Packet, #state{sock = Sock, codec = Codec} = St) ->
...
@@ -210,10 +223,16 @@ down_send(Packet, #state{sock = Sock, codec = Codec} = St) ->
up_send
(
Packet
,
ConnId
,
#state
{
upstreams_rev
=
UpsRev
}
=
St
)
->
up_send
(
Packet
,
ConnId
,
#state
{
upstreams_rev
=
UpsRev
}
=
St
)
->
%% lager:debug("Down>Up: ~w", [Packet]),
case
maps
:
find
(
ConnId
,
UpsRev
)
of
Upstream
=
maps
:
get
(
ConnId
,
UpsRev
),
{
ok
,
Upstream
}
->
ok
=
mtp_handler
:
send
(
Upstream
,
Packet
),
ok
=
mtp_handler
:
send
(
Upstream
,
Packet
),
St
.
St
;
error
->
lager
:
warning
(
"Unknown connection_id=
~w
; ups=
~w
"
,
[
ConnId
,
maps
:
keys
(
UpsRev
)]),
ClosedPacket
=
mtp_rpc
:
encode_packet
(
remote_closed
,
ConnId
),
{
ok
,
St1
}
=
down_send
(
ClosedPacket
,
St
),
St1
end
.
connect
(
DcId
,
S
)
->
connect
(
DcId
,
S
)
->
{
ok
,
{
Host
,
Port
}}
=
mtp_config
:
get_netloc
(
DcId
),
{
ok
,
{
Host
,
Port
}}
=
mtp_config
:
get_netloc
(
DcId
),
...
...
src/mtp_handler.erl
View file @
b0f6ee29
...
@@ -294,10 +294,12 @@ handle_upstream_header(DcId, #state{acc = Acc, ad_tag = Tag, addr = Addr} = S) -
...
@@ -294,10 +294,12 @@ handle_upstream_header(DcId, #state{acc = Acc, ad_tag = Tag, addr = Addr} = S) -
{
RealDcId
,
_
Pool
,
Downstream
}
=
mtp_config
:
get_downstream_safe
(
DcId
,
Opts
),
{
RealDcId
,
_
Pool
,
Downstream
}
=
mtp_config
:
get_downstream_safe
(
DcId
,
Opts
),
handle_upstream_data
(
handle_upstream_data
(
Acc
,
Acc
,
S
#state
{
down
=
Downstream
,
switch_timer
(
dc_id
=
RealDcId
,
S
#state
{
down
=
Downstream
,
acc
=
<<>>
,
dc_id
=
RealDcId
,
stage
=
tunnel
}).
acc
=
<<>>
,
stage
=
tunnel
},
hibernate
)).
hex
(
Bin
)
->
hex
(
Bin
)
->
<<
begin
<<
begin
...
...
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