7373% % @param Options options for distribution. Supported options are:
7474% % - `name_domain' : whether name should be short or long
7575% % - `proto_dist' : the module used for distribution (e.g. `socket_dist')
76- % % - `dist_listen_min' : defines the min port range for the listener socket.
77- % % - `dist_listen_max' : defines the max port range for the listener socket.
76+ % % - `dist_opts' : a map of options passed through to the dist module's `listen/2'
7877% %-----------------------------------------------------------------------------
7978-spec start (atom (), map ()) -> {ok , pid ()}.
8079start (Name , Options0 ) when is_atom (Name ) andalso is_map (Options0 ) ->
@@ -83,31 +82,12 @@ start(Name, Options0) when is_atom(Name) andalso is_map(Options0) ->
8382 case Key of
8483 name_domain when Val =:= shortnames orelse Val =:= longnames -> ok ;
8584 proto_dist when is_atom (Val ) -> ok ;
86- dist_listen_min when is_integer (Val ) -> ok ;
87- dist_listen_max when is_integer (Val ) -> ok ;
85+ dist_opts when is_map (Val ) -> ok ;
8886 _ -> error ({invalid_option , Key , Val }, [Name , Options0 ])
8987 end
9088 end ,
9189 Options0
9290 ),
93- % Check that if one of dist_listen_min and dist_listen_max are configured, both are configured.
94- % And verify dist_listen_max is larger or equal to dist_listen_min.
95- ok =
96- case {maps :is_key (dist_listen_min , Options0 ), maps :is_key (dist_listen_max , Options0 )} of
97- {true , false } ->
98- error (missing_dist_listen_max , [Name , Options0 ]);
99- {false , true } ->
100- error (missing_dist_listen_min , [Name , Options0 ]);
101- {true , true } ->
102- Min = maps :get (dist_listen_min , Options0 ),
103- Max = maps :get (dist_listen_max , Options0 ),
104- if
105- Min > Max -> error (invalid_port_range , [Name , Options0 ]);
106- true -> ok
107- end ;
108- _ ->
109- ok
110- end ,
11191 Options1 = Options0 #{name => Name },
11292 Options2 = split_name (Options1 ),
11393 net_kernel_sup :start (Options2 );
@@ -211,14 +191,14 @@ init(Options) ->
211191 process_flag (trap_exit , true ),
212192 LongNames = maps :get (name_domain , Options , longnames ) =:= longnames ,
213193 ProtoDist = maps :get (proto_dist , Options , socket_dist ),
214- ListenOpts = maps :with ([ dist_listen_min , dist_listen_max ], Options ),
194+ DistOpts = maps :get ( dist_opts , Options , #{} ),
215195 Name = maps :get (name , Options ),
216196 Node = maps :get (node , Options ),
217197 Cookie = crypto :strong_rand_bytes (16 ),
218198 TickInterval = (? NET_TICK_TIME * 1000 ) div ? NET_TICK_INTENSITY ,
219199 Self = self (),
220200 Ticker = spawn_link (fun () -> ticker (Self , TickInterval ) end ),
221- case ProtoDist :listen (Name , ListenOpts ) of
201+ case ProtoDist :listen (Name , DistOpts ) of
222202 {ok , {Listen , _Address , Creation }} ->
223203 true = erlang :setnode (Node , Creation ),
224204 AcceptPid = ProtoDist :accept (Listen ),
0 commit comments