Add fake telegram "middle-proxy" server and http config server implementations

And make it possible to make proxy connect to it
parent aa6e06a4
...@@ -168,11 +168,13 @@ update(State, _) -> ...@@ -168,11 +168,13 @@ update(State, _) ->
end. end.
update_key(Tab) -> update_key(Tab) ->
{ok, Body} = http_get(?SECRET_URL), Url = application:get_env(mtproto_proxy, proxy_secret_url, ?SECRET_URL),
{ok, Body} = http_get(Url),
true = ets:insert(Tab, {key, list_to_binary(Body)}). true = ets:insert(Tab, {key, list_to_binary(Body)}).
update_config(Tab) -> update_config(Tab) ->
{ok, Body} = http_get(?CONFIG_URL), Url = application:get_env(mtproto_proxy, proxy_config_url, ?CONFIG_URL),
{ok, Body} = http_get(Url),
Downstreams = parse_config(Body), Downstreams = parse_config(Body),
update_downstreams(Downstreams, Tab), update_downstreams(Downstreams, Tab),
update_ids(Downstreams, Tab). update_ids(Downstreams, Tab).
......
...@@ -63,12 +63,17 @@ ...@@ -63,12 +63,17 @@
%% Should be module with function `notify/4' exported. %% Should be module with function `notify/4' exported.
%% See mtp_metric:notify/4 for details %% See mtp_metric:notify/4 for details
%% {metric_backend, my_metric_backend} %% {metric_backend, my_metric_backend},
%% 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, 512000} %500kb %% {downstream_socket_buffer_size, 512000}, %500kb
%% Where to fetch telegram proxy configuration
%% Mostly used to testing
%% {proxy_secret_url, "https://core.telegram.org/getProxySecret"},
%% {proxy_config_url, "https://core.telegram.org/getProxyConfig"},
]}, ]},
{modules, []}, {modules, []},
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
%% API %% API
%%==================================================================== %%====================================================================
start(_StartType, _StartArgs) -> start(_StartType, _StartArgs) ->
Res = mtproto_proxy_sup:start_link(), Res = {ok, _} = mtproto_proxy_sup:start_link(),
io:format("+++++++++++++++++++++++++++++++++++++++~n" io:format("+++++++++++++++++++++++++++++++++++++++~n"
"Erlang MTProto proxy by @seriyps https://github.com/seriyps/mtproto_proxy~n" "Erlang MTProto proxy by @seriyps https://github.com/seriyps/mtproto_proxy~n"
"Sponsored by and powers @socksy_bot~n"), "Sponsored by and powers @socksy_bot~n"),
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment