Permalink
Browse files

Avoids converting a ClientIp to a tuple when conversion is unnecessary.

  • Loading branch information...
1 parent 0ad02e6 commit 2e2994a5e7140d1f751bf9e49e8daee2b9d14f0d @imperialwicket imperialwicket committed Jun 14, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/lib/cb_admin_lib.erl
View
@@ -16,7 +16,8 @@ mask_ipv4_address({I1, I2, I3, I4}, MaskInt) ->
require_ip_address(Req) ->
ClientIp = case Req:header(x_forwarded_for) of
undefined -> Req:peer_ip();
- IP -> list_to_tuple(lists:map(fun erlang:list_to_integer/1, string:tokens(IP, ".")))
+ IP when is_tuple(IP)-> IP;
+ IP when is_list(IP) -> list_to_tuple(lists:map(fun erlang:list_to_integer/1, string:tokens(IP, ".")))
end,
Authorized = lists:foldr(fun
(IPBlock, false) ->

0 comments on commit 2e2994a

Please sign in to comment.