Make it possible to configure each listener's interface IP

parent 4eab3caa
...@@ -30,10 +30,15 @@ ...@@ -30,10 +30,15 @@
%% {external_ip, "YOUR.SERVER.EXTERNAL.IP"}, %% {external_ip, "YOUR.SERVER.EXTERNAL.IP"},
%% Interface to listen for incoming connections %% 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 %% 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,
%% 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 should be 32 hex chars [0-9a-f]
secret => <<"d0d6e111bada5511fcce9584deadbeef">>, secret => <<"d0d6e111bada5511fcce9584deadbeef">>,
%% tag is what you get from @MTProxybot %% tag is what you get from @MTProxybot
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
-behaviour(application). -behaviour(application).
%% Application callbacks %% Application callbacks
-export([start/2, stop/1]). -export([start/2, stop/1, start_proxy/1]).
-define(APP, mtproto_proxy). -define(APP, mtproto_proxy).
%%==================================================================== %%====================================================================
...@@ -30,8 +30,10 @@ stop(_State) -> ...@@ -30,8 +30,10 @@ stop(_State) ->
%%==================================================================== %%====================================================================
%% Internal functions %% Internal functions
%%==================================================================== %%====================================================================
start_proxy(#{name := Name, port := Port, secret := Secret, tag := Tag}) -> start_proxy(#{name := Name, port := Port, secret := Secret, tag := Tag} = P) ->
ListenIp = application:get_env(?APP, ip, {0, 0, 0, 0}), ListenIp = maps:get(
listen_ip, P,
application:get_env(?APP, listen_ip, {0, 0, 0, 0})),
NumAcceptors = application:get_env(?APP, num_acceptors, 60), NumAcceptors = application:get_env(?APP, num_acceptors, 60),
MaxConnections = application:get_env(?APP, max_connections, 10240), MaxConnections = application:get_env(?APP, max_connections, 10240),
Res = 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