aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch_server.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-08-25 18:49:58 +0200
committerLoïc Hoguin <[email protected]>2015-08-25 18:49:58 +0200
commit236d0f8eec82eb43c566d4aa6d2532e1318665f3 (patch)
tree58de9af7309094a3896fdebf21fce0f37f917d6c /src/ranch_server.erl
parentd1cd1674e8dd8ef3f9bc2b5d3e86d95a3dbceb0d (diff)
downloadranch-236d0f8eec82eb43c566d4aa6d2532e1318665f3.tar.gz
ranch-236d0f8eec82eb43c566d4aa6d2532e1318665f3.tar.bz2
ranch-236d0f8eec82eb43c566d4aa6d2532e1318665f3.zip
Add ranch:get_addr/1
Diffstat (limited to 'src/ranch_server.erl')
-rw-r--r--src/ranch_server.erl22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ranch_server.erl b/src/ranch_server.erl
index c132fa3..55ebafb 100644
--- a/src/ranch_server.erl
+++ b/src/ranch_server.erl
@@ -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}),