mtproto_proxy/config/sys.config.back.example
Sergey Prokhorov 42d86517a4
Add split-mode: front/back nodes via Erlang distribution
Adds `node_role = front | back | both` (default `both` — no behaviour change).
In split mode the domestic front node runs Ranch listeners and session/policy
processes; the foreign back node runs mtp_config, DC pools, and downstream
connections.

The key implementation insight: Erlang's transparent distributed process
addressing means `gen_server:call({mtp_dc_pool_1, BackNode}, ...)` works
identically to a local call — zero changes to the hot-path message protocol.
Process monitors fire on node disconnection, so back-node restarts propagate
cleanly to front-node handlers without any watcher process.

Changes:
- mtproto_proxy_sup: role-parameterised children/1
- mtproto_proxy_app: role-gated start, config_changed, port management
- mtp_config: backend_node/0, remote-aware get_downstream_pool/1 and
  get_default_dc/0 using erpc:call; get_downstream_safe/2 dispatches
  remotely in front mode
- mtp_metric: passive_metrics/0 skips unavailable gauges per role
- split_dc_SUITE: two CT cases (echo, migration) on OTP peer nodes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-11 23:33:09 +02:00

54 lines
1.8 KiB
Erlang

%% -*- mode: erlang -*-
%%
%% sys.config for the BACK node (foreign server).
%%
%% The back node runs DC pool connections to Telegram.
%% It does NOT listen for client connections — that is done by the front node(s).
%%
%% Multiple front nodes can share one back node.
%% Start the back node first so pools are ready when fronts connect.
%%
[
{mtproto_proxy,
[
%% This node is a back-end only.
{node_role, back},
%% No `ports' section — the back node does not accept client connections.
%% Telegram proxy secret (fetched from core.telegram.org).
%% Defaults are fine; override only if you need a custom URL.
%% {proxy_secret_url, "https://core.telegram.org/getProxySecret"},
%% {proxy_config_url, "https://core.telegram.org/getProxyConfig"},
%% The back node must know its external IP for Telegram's encryption.
%% Either set it explicitly or let ip_lookup_services resolve it.
%% {external_ip, "YOUR.BACK.NODE.EXTERNAL.IP"},
{ip_lookup_services,
["http://ipv4.seriyps.com/",
"http://v4.ident.me/",
"http://ipv4.icanhazip.com/",
"https://digitalresistance.dog/myIp"]},
%% Multiplexing tuning (back node creates DC connections).
%% {init_dc_connections, 2},
%% {clients_per_dc_connection, 300}
]},
{kernel,
[{logger_level, info},
{logger,
[{handler, default, logger_std_h,
#{level => info,
config => #{type => file,
file => "/var/log/mtproto-proxy/back.log",
max_no_bytes => 104857600,
max_no_files => 10,
filesync_repeat_interval => no_repeat}}},
{handler, console, logger_std_h,
#{level => critical,
config => #{type => standard_io}}}
]}]},
{sasl,
[{errlog_type, error}]}
].