erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.19k stars 2.92k forks source link

erl_boot_server:init(Slaves) will start a random TCP port #7365

Open wojiaozouzy opened 1 year ago

wojiaozouzy commented 1 year ago

Describe the bug erl_boot_server:init(Slaves) will start a random TCP port The firewall cannot specify the port To Reproduce

Expected behavior Pass in parameters to specify the port

Affected versions all

Additional context

init(Slaves) ->
    {ok, U} = gen_udp:open(?EBOOT_PORT, []),
    {ok, L} = gen_tcp:listen(0, [binary,{packet,4}]),
    {ok, Port} = inet:port(L),
    {ok, UPort} = inet:port(U),
    Ref = make_ref(),
    Pid = proc_lib:spawn_link(?MODULE, boot_init, [Ref]),
    ok = gen_tcp:controlling_process(L, Pid),
    Pid ! {Ref, L},
    %% We trap exit inorder to restart boot_init and udp_port 
    process_flag(trap_exit, true),
    {ok, #state{priority = 0,
        version = erlang:system_info(version),
        udp_sock = U,
        udp_port = UPort,
        listen_sock = L,
        listen_port = Port,
        slaves = ordsets:from_list(Slaves),
        bootp = Pid
           }}.
garazdawi commented 1 year ago

Hello! I agree that this is something that would be nice to have, but it is not something that we will work on. If you need it a PR with code change + docs + tests would be much appreciated.