diff options
author | Loïc Hoguin <[email protected]> | 2016-11-08 16:38:21 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-11-08 16:38:21 +0200 |
commit | b2b099627424ce42b7f0ac02e5ddd8d0bf2c3381 (patch) | |
tree | 1030a3899d9b7da9364d38b96b3f2ae1340cd6ef /src/ranch.erl | |
parent | 4d487ac60c3a4962a8280acfcf265b2523b2d76e (diff) | |
download | ranch-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.erl')
-rw-r--r-- | src/ranch.erl | 18 |
1 files changed, 9 insertions, 9 deletions
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([], _) -> []. |