From b2b099627424ce42b7f0ac02e5ddd8d0bf2c3381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 8 Nov 2016 16:38:21 +0200 Subject: 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. --- src/ranch_tcp.erl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/ranch_tcp.erl') 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()}. -- cgit v1.2.3