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
4f30749d
Unverified
Commit
4f30749d
authored
Oct 27, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make multiplexed downstream socket buffer size tunable
parent
0af1923c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
mtp_down_conn.erl
src/mtp_down_conn.erl
+5
-5
mtproto_proxy.app.src
src/mtproto_proxy.app.src
+2
-2
No files found.
src/mtp_down_conn.erl
View file @
4f30749d
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
-
define
(
APP
,
mtproto_proxy
).
-
define
(
APP
,
mtproto_proxy
).
-
define
(
CONN_TIMEOUT
,
10000
).
-
define
(
CONN_TIMEOUT
,
10000
).
-
define
(
SEND_TIMEOUT
,
15000
).
-
define
(
SEND_TIMEOUT
,
15000
).
-
define
(
MAX_SOCK_BUF_SIZE
,
1024
*
3
00
).
% Decrease if CPU is cheaper than RAM
-
define
(
MAX_SOCK_BUF_SIZE
,
1024
*
5
00
).
% Decrease if CPU is cheaper than RAM
-
type
handle
()
::
pid
().
-
type
handle
()
::
pid
().
-
type
upstream_opts
()
::
#
{
addr
:
=
mtp_config
:
netloc
(),
% IP/Port of TG client
-
type
upstream_opts
()
::
#
{
addr
:
=
mtp_config
:
netloc
(),
% IP/Port of TG client
...
@@ -262,17 +262,17 @@ connect(DcId, S) ->
...
@@ -262,17 +262,17 @@ connect(DcId, S) ->
end
.
end
.
tcp_connect
(
Host
,
Port
)
->
tcp_connect
(
Host
,
Port
)
->
BufSize
=
application
:
get_env
(
?
APP
,
downstream_socket_buffer_size
,
?
MAX_SOCK_BUF_SIZE
),
SockOpts
=
[{
active
,
once
},
SockOpts
=
[{
active
,
once
},
{
packet
,
raw
},
{
packet
,
raw
},
binary
,
{
mode
,
binary
},
{
buffer
,
BufSize
},
{
send_timeout
,
?
SEND_TIMEOUT
},
{
send_timeout
,
?
SEND_TIMEOUT
},
%% {nodelay, true},
%% {nodelay, true},
{
keepalive
,
true
}],
{
keepalive
,
true
}],
case
gen_tcp
:
connect
(
Host
,
Port
,
SockOpts
,
?
CONN_TIMEOUT
)
of
case
gen_tcp
:
connect
(
Host
,
Port
,
SockOpts
,
?
CONN_TIMEOUT
)
of
{
ok
,
Sock
}
->
{
ok
,
Sock
}
->
ok
=
inet
:
setopts
(
Sock
,
[
%% {recbuf, ?MAX_SOCK_BUF_SIZE},
%% {sndbuf, ?MAX_SOCK_BUF_SIZE},
{
buffer
,
?
MAX_SOCK_BUF_SIZE
}]),
{
ok
,
Sock
};
{
ok
,
Sock
};
{
error
,
_}
=
Err
->
{
error
,
_}
=
Err
->
Err
Err
...
...
src/mtproto_proxy.app.src
View file @
4f30749d
{application, mtproto_proxy,
{application, mtproto_proxy,
[{description, "An OTP application"},
[{description, "An OTP application"},
{vsn, "0.4.
0
"},
{vsn, "0.4.
1-mux
"},
{registered, []},
{registered, []},
{mod, { mtproto_proxy_app, []}},
{mod, { mtproto_proxy_app, []}},
{applications,
{applications,
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
%% User-space recv socket buffer sizes. Set to higher if you have
%% User-space recv socket buffer sizes. Set to higher if you have
%% enough RAM
%% enough RAM
%% {upstream_socket_buffer_size, 51200}, %50kb
%% {upstream_socket_buffer_size, 51200}, %50kb
%% {downstream_socket_buffer_size, 51200
} %5
0kb
%% {downstream_socket_buffer_size, 51200
0} %50
0kb
]},
]},
{modules, []},
{modules, []},
...
...
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