aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch_tcp.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-11-08 16:38:21 +0200
committerLoïc Hoguin <[email protected]>2016-11-08 16:38:21 +0200
commitb2b099627424ce42b7f0ac02e5ddd8d0bf2c3381 (patch)
tree1030a3899d9b7da9364d38b96b3f2ae1340cd6ef /src/ranch_tcp.erl
parent4d487ac60c3a4962a8280acfcf265b2523b2d76e (diff)
downloadranch-b2b099627424ce42b7f0ac02e5ddd8d0bf2c3381.tar.gz
ranch-b2b099627424ce42b7f0ac02e5ddd8d0bf2c3381.tar.bz2
ranch-b2b099627424ce42b7f0ac02e5ddd8d0bf2c3381.zip
Blacklist listen options instead of whitelist
Dialyzer will still complain about unknown options, but at least users won't be stuck waiting for an upstream update.
Diffstat (limited to 'src/ranch_tcp.erl')
-rw-r--r--src/ranch_tcp.erl16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl
index 958b3f9..c2ad148 100644
--- a/src/ranch_tcp.erl
+++ b/src/ranch_tcp.erl
@@ -19,7 +19,7 @@
-export([secure/0]).
-export([messages/0]).
-export([listen/1]).
--export([listen_options/0]).
+-export([disallowed_listen_options/0]).
-export([accept/2]).
-export([accept_ack/2]).
-export([connect/3]).
@@ -83,19 +83,13 @@ listen(Opts) ->
%% We set the port to 0 because it is given in the Opts directly.
%% The port in the options takes precedence over the one in the
%% first argument.
- gen_tcp:listen(0, ranch:filter_options(Opts5, listen_options(),
+ gen_tcp:listen(0, ranch:filter_options(Opts5, disallowed_listen_options(),
[binary, {active, false}, {packet, raw}, {reuseaddr, true}])).
-%% 'inet' and 'inet6' are also allowed but they are handled
+%% 'binary' and 'list' are disallowed but they are handled
%% specifically as they do not have 2-tuple equivalents.
-%%
-%% The 4-tuple 'raw' option is also handled specifically.
-listen_options() ->
- [backlog, buffer, delay_send, dontroute, exit_on_close, fd,
- high_msgq_watermark, high_watermark, ip, ipv6_v6only,
- keepalive, linger, low_msgq_watermark,
- low_watermark, nodelay, port, priority, recbuf,
- send_timeout, send_timeout_close, sndbuf, tos].
+disallowed_listen_options() ->
+ [active, header, mode, packet, packet_size, line_delimiter, reuseaddr].
-spec accept(inet:socket(), timeout())
-> {ok, inet:socket()} | {error, closed | timeout | atom()}.