Skip to content

Commit

Permalink
add -spec for dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
yueyoum committed Nov 10, 2014
1 parent 6b2e09e commit 6bab770
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/src/mpc_child.erl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ code_change(_OldVsn, State, _Extra) ->
%%% Internal functions
%%%===================================================================

-spec start_process(port(), nonempty_string()) -> {ok, port()} |
{error, any()}.
start_process(Socket, Key) ->
{ok, RemoteAddr} = application:get_env(make_proxy_client, remote_addr),
{ok, RemotePort} = application:get_env(make_proxy_client, remote_port),
Expand All @@ -195,6 +197,7 @@ start_process(Socket, Key) ->
end.


-spec find_target(port()) -> {ok, <<_:32, _:_*8>>}.
find_target(Socket) ->
{ok, <<5:8, Nmethods:8>>} = gen_tcp:recv(Socket, 2),
{ok, _Methods} = gen_tcp:recv(Socket, Nmethods),
Expand Down
3 changes: 3 additions & 0 deletions common/mp_crypto.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-define(DATALENGTH, 16).
-define(IV, <<"90de3456asxdfrtg">>).

-spec encrypt(nonempty_string(), binary()) -> <<_:_*8>>.
encrypt(Key, Binary) ->
BinaryLength = byte_size(Binary),
Rem = (BinaryLength + 4) rem ?DATALENGTH,
Expand All @@ -15,6 +16,8 @@ encrypt(Key, Binary) ->
crypto:block_encrypt(aes_cbc128, Key, ?IV, FinalBinary).


-spec decrypt(nonempty_string(), <<_:_*8>>) -> {ok, binary()} |
{error, term()}.
decrypt(Key, Binary) ->
Data = crypto:block_decrypt(aes_cbc128, Key, ?IV, Binary),
try
Expand Down
5 changes: 5 additions & 0 deletions server/src/mp_child.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ code_change(_OldVsn, State, _Extra) ->
%%% Internal functions
%%%===================================================================

-spec connect_to_remote(port(), nonempty_string()) -> {ok, {list()|tuple(), non_neg_integer()}} |
{error, term()}.
connect_to_remote(Socket, Key) ->
{ok, EntrypedData} = gen_tcp:recv(Socket, 0),

Expand All @@ -193,6 +195,7 @@ connect_to_remote(Socket, Key) ->
end.


-spec parse_address(non_neg_integer(), binary()) -> {ok, {list()|tuple(), non_neg_integer()}}.
parse_address(?IPV4, Data) ->
<<Port:16, Destination/binary>> = Data,
Address = list_to_tuple( binary_to_list(Destination) ),
Expand All @@ -210,6 +213,8 @@ parse_address(?DOMAIN, Data) ->
{ok, {Address, Port}}.


-spec connect_target(list() | tuple(), non_neg_integer()) -> {ok, port()} |
{error, term()}.
connect_target(Address, Port) ->
connect_target(Address, Port, 2).

Expand Down

0 comments on commit 6bab770

Please sign in to comment.