Make it possible to configure each listener's interface IP

parent 4eab3caa
......@@ -30,10 +30,15 @@
%% {external_ip, "YOUR.SERVER.EXTERNAL.IP"},
%% Interface to listen for incoming connections
{ip, {0, 0, 0, 0}},
%% If not set, 0.0.0.0 will be used
{listen_ip, {0, 0, 0, 0}},
%% You can add as much as you want. Names and ports should be unique
{ports, [#{name => mtp_handler,
port => 1443,
%% You can tell it to listen on specific IP.
%% If not set, top-level listen_ip will be used.
%% listen_ip => {1, 2, 3, 4},
%% secret should be 32 hex chars [0-9a-f]
secret => <<"d0d6e111bada5511fcce9584deadbeef">>,
%% tag is what you get from @MTProxybot
......
......@@ -8,7 +8,7 @@
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
-export([start/2, stop/1, start_proxy/1]).
-define(APP, mtproto_proxy).
%%====================================================================
......@@ -30,8 +30,10 @@ stop(_State) ->
%%====================================================================
%% Internal functions
%%====================================================================
start_proxy(#{name := Name, port := Port, secret := Secret, tag := Tag}) ->
ListenIp = application:get_env(?APP, ip, {0, 0, 0, 0}),
start_proxy(#{name := Name, port := Port, secret := Secret, tag := Tag} = P) ->
ListenIp = maps:get(
listen_ip, P,
application:get_env(?APP, listen_ip, {0, 0, 0, 0})),
NumAcceptors = application:get_env(?APP, num_acceptors, 60),
MaxConnections = application:get_env(?APP, max_connections, 10240),
Res =
......
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