Skip to content

Commit

Permalink
Delete trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumthinker committed Sep 28, 2017
1 parent cc5125c commit 1def067
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/eradius_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ send_request(NAS, Request) ->

% @doc Send a radius request to the given NAS.
% If no answer is received within the specified timeout, the request will be sent again.
-spec send_request(nas_address(), #radius_request{}, options()) ->
-spec send_request(nas_address(), #radius_request{}, options()) ->
{ok, binary(), eradius_lib:authenticator()} | {error, 'timeout' | 'socket_down'}.
send_request({IP, Port, Secret}, Request, Options) when ?GOOD_CMD(Request) andalso is_tuple(IP) ->
TS1 = eradius_metrics:timestamp(milli_seconds),
Expand Down
8 changes: 4 additions & 4 deletions src/eradius_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,18 @@ ok_error_helper({error, _Error}, ErrorMsg) when is_list(ErrorMsg) -> ErrorMsg;
ok_error_helper({ok, Value}, _ErrorMessage) -> Value;
ok_error_helper(Value, _ErrorMessage) -> Value.

generate_ip_list(IP, Mask) when is_list(Mask) ->
generate_ip_list(IP, Mask) when is_list(Mask) ->
generate_ip_list(IP, catch list_to_integer(Mask));
generate_ip_list({A, B, C, D}, Mask) when Mask >=0, Mask =< 32 ->
generate_ip_list({A, B, C, D}, Mask) when Mask >=0, Mask =< 32 ->
<<Address:32/integer>> = <<A, B, C, D>>,
Wildcard = 16#ffffffff bsr Mask,
<<Netmask:32/unsigned-integer>> = << (bnot Wildcard):32 >>,
generate_ip(Address band Netmask, Address bor Wildcard);
generate_ip_list(_, Mask) -> ?invalid("invalid mask ~p", [Mask]).

generate_ip(E, E) ->
generate_ip(E, E) ->
<<A:8, B:8, C:8, D:8>> = <<E:32/integer>>,
[{A, B, C, D}];
generate_ip(S, E) ->
generate_ip(S, E) ->
<<A:8, B:8, C:8, D:8>> = <<S:32/integer>>,
[{A, B, C, D} | generate_ip(S+1, E)].
2 changes: 1 addition & 1 deletion src/eradius_eap_packet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
decode(<<Code:8, Id:8, Len:16, Rest/binary>>) ->
DataLen = Len - 4,
case Rest of
<<Data:DataLen/bytes, _/binary>> ->
<<Data:DataLen/bytes, _/binary>> ->
do_decode_payload(code(Code), Id, Data);
_ ->
{error, invalid_length}
Expand Down
14 changes: 7 additions & 7 deletions src/eradius_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ validate_packet_authenticator(Cmd, ReqId, Len, Auth, Body, Pos, Secret) ->
case Body of
<<Before:Pos/bytes, Value:16/bytes, After/binary>> ->
case crypto:hmac(md5, Secret, [<<Cmd:8, ReqId:8, Len:16>>, Auth, Before, zero_authenticator(), After]) of
Value ->
Value ->
ok;
_ ->
_ ->
throw({bad_pdu, "Message-Authenticator Attribute is invalid"})
end;
_ ->
Expand All @@ -283,7 +283,7 @@ validate_packet_authenticator(Cmd, ReqId, Len, Auth, Body, Pos, Secret) ->
validate_authenticator(accreq, Head, _RequestAuthenticator, PacketAuthenticator, Body, Secret) ->
compare_authenticator(crypto:hash(md5, [Head, zero_authenticator(), Body, Secret]), PacketAuthenticator);
validate_authenticator(Cmd, Head, RequestAuthenticator, PacketAuthenticator, Body, Secret)
when
when
(Cmd =:= accept) orelse
(Cmd =:= reject) orelse
(Cmd =:= accresp) orelse
Expand All @@ -294,10 +294,10 @@ validate_authenticator(Cmd, Head, RequestAuthenticator, PacketAuthenticator, Bod
(Cmd =:= challenge) ->
compare_authenticator(crypto:hash(md5, [Head, RequestAuthenticator, Body, Secret]), PacketAuthenticator);
validate_authenticator(_Cmd, _Head, _RequestAuthenticator, _PacketAuthenticator,
_Body, _Secret) ->
_Body, _Secret) ->
true.

compare_authenticator(Authenticator, Authenticator) ->
compare_authenticator(Authenticator, Authenticator) ->
true;
compare_authenticator(_RequestAuthenticator, _PacketAuthenticator) ->
throw({bad_pdu, "Authenticator Attribute is invalid"}).
Expand Down Expand Up @@ -455,7 +455,7 @@ do_scramble(_SharedSecret, _B, << >>, CipherText) ->

-spec generate_salt() -> salt().
generate_salt() ->
<<Salt1, Salt2>> = crypto:strong_rand_bytes(2),
<<Salt1, Salt2>> = crypto:strong_rand_bytes(2),
<<(Salt1 bor 16#80), Salt2>>.

-spec salt_encrypt(salt(), secret(), authenticator(), binary()) -> binary().
Expand Down Expand Up @@ -505,7 +505,7 @@ timestamp() ->
erlang:timestamp()
catch
error:undef ->
% call erlang:now() via erlang:apply/3
% call erlang:now() via erlang:apply/3
% for getting rid annoying compile warning on OTP >= 18
erlang:apply(erlang, now, [])
end.
Expand Down
2 changes: 1 addition & 1 deletion src/eradius_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ handle_cast({write_request, Time, Sender, Request}, State) ->
{noreply, State}
catch
_:Error ->
lager:error("Failed to log RADIUS request: error: ~p, request: ~p, sender: ~p, "
lager:error("Failed to log RADIUS request: error: ~p, request: ~p, sender: ~p, "
"logging will be disabled", [Error, Request, Sender]),
{noreply, logger_disabled}
end.
Expand Down
6 changes: 3 additions & 3 deletions src/eradius_proxy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ validate_option(_, _) -> false.


% @private
-spec new_request(Request :: #radius_request{},
Username :: undefined | binary(),
-spec new_request(Request :: #radius_request{},
Username :: undefined | binary(),
NewUsername :: string()) ->
NewRequest :: #radius_request{}.
new_request(Request, Username, Username) -> Request;
Expand All @@ -102,7 +102,7 @@ new_request(Request, _Username, NewUsername) ->
?User_Name, NewUsername).

% @private
-spec resolve_routes(Username :: undefined | binary(), DefaultRoute :: route(),
-spec resolve_routes(Username :: undefined | binary(), DefaultRoute :: route(),
Routes :: routes(), Options :: [proplists:property()]) ->
{NewUsername :: string(), Route :: route()}.
resolve_routes( undefined, {_, _, _DefaultSecret} = DefaultRoute, _Routes, _Options) ->
Expand Down
4 changes: 2 additions & 2 deletions src/eradius_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ init({ServerName, IP, Port}) ->
end.

%% @private
handle_info(ReqUDP = {udp, Socket, FromIP, FromPortNo, Packet},
handle_info(ReqUDP = {udp, Socket, FromIP, FromPortNo, Packet},
State = #state{name = ServerName, transacts = Transacts, ip = IP, port = Port}) ->
TS1 = eradius_metrics:timestamp(milli_seconds),
ServerAddress = {ServerName, {IP, Port}},
Expand Down Expand Up @@ -322,7 +322,7 @@ apply_handler_mod(HandlerMod, HandlerArg, Request, NasProp) ->
eradius_log:write_request(Sender, Reply),
{reply, EncReply,{Request#radius_request.cmd, ReplyCmd}};
noreply ->
lager:error("~s INF: Noreply for request ~p from handler ~p: returned value: ~p",
lager:error("~s INF: Noreply for request ~p from handler ~p: returned value: ~p",
[printable_peer(ServerIP, Port), Request, HandlerArg, noreply]),
{discard, handler_returned_noreply};
{error, timeout} ->
Expand Down

0 comments on commit 1def067

Please sign in to comment.