|
@@ -21,8 +21,8 @@
|
|
|
-export([cleanup_listener_opts/1]).
|
|
|
-export([set_connections_sup/2]).
|
|
|
-export([get_connections_sup/1]).
|
|
|
--export([set_port/2]).
|
|
|
--export([get_port/1]).
|
|
|
+-export([set_addr/2]).
|
|
|
+-export([get_addr/1]).
|
|
|
-export([set_max_connections/2]).
|
|
|
-export([get_max_connections/1]).
|
|
|
-export([set_protocol_options/2]).
|
|
@@ -56,7 +56,7 @@ set_new_listener_opts(Ref, MaxConns, Opts) ->
|
|
|
|
|
|
-spec cleanup_listener_opts(ranch:ref()) -> ok.
|
|
|
cleanup_listener_opts(Ref) ->
|
|
|
- _ = ets:delete(?TAB, {port, Ref}),
|
|
|
+ _ = ets:delete(?TAB, {addr, Ref}),
|
|
|
_ = ets:delete(?TAB, {max_conns, Ref}),
|
|
|
_ = ets:delete(?TAB, {opts, Ref}),
|
|
|
ok.
|
|
@@ -70,13 +70,13 @@ set_connections_sup(Ref, Pid) ->
|
|
|
get_connections_sup(Ref) ->
|
|
|
ets:lookup_element(?TAB, {conns_sup, Ref}, 2).
|
|
|
|
|
|
--spec set_port(ranch:ref(), inet:port_number()) -> ok.
|
|
|
-set_port(Ref, Port) ->
|
|
|
- gen_server:call(?MODULE, {set_port, Ref, Port}).
|
|
|
+-spec set_addr(ranch:ref(), {inet:ip_address(), inet:port_number()}) -> ok.
|
|
|
+set_addr(Ref, Addr) ->
|
|
|
+ gen_server:call(?MODULE, {set_addr, Ref, Addr}).
|
|
|
|
|
|
--spec get_port(ranch:ref()) -> inet:port_number().
|
|
|
-get_port(Ref) ->
|
|
|
- ets:lookup_element(?TAB, {port, Ref}, 2).
|
|
|
+-spec get_addr(ranch:ref()) -> {inet:ip_address(), inet:port_number()}.
|
|
|
+get_addr(Ref) ->
|
|
|
+ ets:lookup_element(?TAB, {addr, Ref}, 2).
|
|
|
|
|
|
-spec set_max_connections(ranch:ref(), ranch:max_conns()) -> ok.
|
|
|
set_max_connections(Ref, MaxConnections) ->
|
|
@@ -119,8 +119,8 @@ handle_call({set_connections_sup, Ref, Pid}, _,
|
|
|
false ->
|
|
|
{reply, false, State}
|
|
|
end;
|
|
|
-handle_call({set_port, Ref, Port}, _, State) ->
|
|
|
- true = ets:insert(?TAB, {{port, Ref}, Port}),
|
|
|
+handle_call({set_addr, Ref, Addr}, _, State) ->
|
|
|
+ true = ets:insert(?TAB, {{addr, Ref}, Addr}),
|
|
|
{reply, ok, State};
|
|
|
handle_call({set_max_conns, Ref, MaxConns}, _, State) ->
|
|
|
ets:insert(?TAB, {{max_conns, Ref}, MaxConns}),
|