Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
erlang
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
erlang
Commits
e9d84061
Unverified
Commit
e9d84061
authored
Jul 05, 2018
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add external IP autodetection
parent
e5533b75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
mtp_config.erl
src/mtp_config.erl
+12
-1
mtproto_proxy.app.src
src/mtproto_proxy.app.src
+17
-2
No files found.
src/mtp_config.erl
View file @
e9d84061
...
@@ -110,7 +110,8 @@ code_change(_OldVsn, State, _Extra) ->
...
@@ -110,7 +110,8 @@ code_change(_OldVsn, State, _Extra) ->
update
(
#state
{
tab
=
Tab
},
force
)
->
update
(
#state
{
tab
=
Tab
},
force
)
->
update_key
(
Tab
),
update_key
(
Tab
),
update_config
(
Tab
);
update_config
(
Tab
),
update_ip
();
update
(
State
,
_)
->
update
(
State
,
_)
->
try
update
(
State
,
force
)
try
update
(
State
,
force
)
catch
Class
:
Reason
->
catch
Class
:
Reason
->
...
@@ -161,6 +162,16 @@ update_downstreams(Downstreams, Tab) ->
...
@@ -161,6 +162,16 @@ update_downstreams(Downstreams, Tab) ->
update_range
(
Range
,
Tab
)
->
update_range
(
Range
,
Tab
)
->
true
=
ets
:
insert
(
Tab
,
{
id_range
,
Range
}).
true
=
ets
:
insert
(
Tab
,
{
id_range
,
Range
}).
update_ip
()
->
case
application
:
get_env
(
?
APP
,
ip_lookup_service
)
of
undefined
->
false
;
{
ok
,
URL
}
->
{
ok
,
{{_,
200
,
_},
_,
Body
}}
=
httpc
:
request
(
URL
),
IpStr
=
string
:
trim
(
Body
),
{
ok
,
_}
=
inet
:
parse_ipv4strict_address
(
IpStr
),
%assert
application
:
set_env
(
?
APP
,
external_ip
,
IpStr
)
end
.
-
ifdef
(
TEST
).
-
ifdef
(
TEST
).
-
include_lib
(
"eunit/include/eunit.hrl"
).
-
include_lib
(
"eunit/include/eunit.hrl"
).
...
...
src/mtproto_proxy.app.src
View file @
e9d84061
...
@@ -13,18 +13,33 @@
...
@@ -13,18 +13,33 @@
stdlib
stdlib
]},
]},
{env,[
{env,[
%% Close connection if it failed to perform handshake in this many seconds
{init_timeout_sec, 60},
{init_timeout_sec, 60},
{hibernate_timeout_sec, 60},
{hibernate_timeout_sec, 60},
%% Close connection after this many seconds of inactivity
{ready_timeout_sec, 1200},
{ready_timeout_sec, 1200},
{ip, {0, 0, 0, 0}},
%% Telegram server uses your external IP address as part of encryption
%% key, so, you should know it.
%% You can configure IP lookup service by `ip_lookup_service' (should
%% return my IP address as one line from this URL) or set IP address
%% statically by `external_ip' (not both).
%% If both are unset, we will try to guess IP address
%% from getsockname().
{ip_lookup_service, "https://digitalresistance.dog/myIp"},
%% {external_ip, "YOUR.SERVER.EXTERNAL.IP"},
%% {external_ip, "YOUR.SERVER.EXTERNAL.IP"},
%% Interface to listen for incoming connections
{ip, {0, 0, 0, 0}},
%% You can add as much as you want. Names and ports should be unique
{ports, [#{name => mtp_handler,
{ports, [#{name => mtp_handler,
port => 1443,
port => 1443,
%% secret should be 32 hex chars [0-9a-f]
secret => <<"d0d6e111bada5511fcce9584deadbeef">>,
secret => <<"d0d6e111bada5511fcce9584deadbeef">>,
%% tag is what you get from @MTProxybot
tag => <<"dcbe8f1493fa4cd9ab300891c0b5b326">>}]},
tag => <<"dcbe8f1493fa4cd9ab300891c0b5b326">>}]},
{num_acceptors, 60},
{num_acceptors, 60},
{max_connections,
2048
0}
{max_connections,
4096
0}
]},
]},
{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