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.erl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/ranch.erl') diff --git a/src/ranch.erl b/src/ranch.erl index 43e940a..7f751cf 100644 --- a/src/ranch.erl +++ b/src/ranch.erl @@ -143,18 +143,18 @@ set_protocol_options(Ref, Opts) -> -spec filter_options([inet | inet6 | {atom(), any()} | {raw, any(), any(), any()}], [atom()], Acc) -> Acc when Acc :: [any()]. -filter_options(UserOptions, AllowedKeys, DefaultOptions) -> - AllowedOptions = filter_user_options(UserOptions, AllowedKeys), +filter_options(UserOptions, DisallowedKeys, DefaultOptions) -> + AllowedOptions = filter_user_options(UserOptions, DisallowedKeys), lists:foldl(fun merge_options/2, DefaultOptions, AllowedOptions). %% 2-tuple options. -filter_user_options([Opt = {Key, _}|Tail], AllowedKeys) -> - case lists:member(Key, AllowedKeys) of - true -> - [Opt|filter_user_options(Tail, AllowedKeys)]; +filter_user_options([Opt = {Key, _}|Tail], DisallowedKeys) -> + case lists:member(Key, DisallowedKeys) of false -> + [Opt|filter_user_options(Tail, DisallowedKeys)]; + true -> filter_options_warning(Opt), - filter_user_options(Tail, AllowedKeys) + filter_user_options(Tail, DisallowedKeys) end; %% Special option forms. filter_user_options([inet|Tail], AllowedKeys) -> @@ -163,9 +163,9 @@ filter_user_options([inet6|Tail], AllowedKeys) -> [inet6|filter_user_options(Tail, AllowedKeys)]; filter_user_options([Opt = {raw, _, _, _}|Tail], AllowedKeys) -> [Opt|filter_user_options(Tail, AllowedKeys)]; -filter_user_options([Opt|Tail], AllowedKeys) -> +filter_user_options([Opt|Tail], DisallowedKeys) -> filter_options_warning(Opt), - filter_user_options(Tail, AllowedKeys); + filter_user_options(Tail, DisallowedKeys); filter_user_options([], _) -> []. -- cgit v1.2.3