Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reformat to 4-space indentation

  • Loading branch information...
commit 0ee1320dc87345494713c44aaba7072bc8cf476d 1 parent 7a28ace
@johannesh johannesh authored
View
4 apps/bitturret/src/bitturret_app.erl
@@ -10,7 +10,7 @@
%% ===================================================================
start(_StartType, _StartArgs) ->
- bitturret_sup:start_link().
+ bitturret_sup:start_link().
stop(_State) ->
- ok.
+ ok.
View
26 apps/bitturret/src/bitturret_handler.erl
@@ -18,10 +18,10 @@
%% ===================================================================
start() ->
- gen_server:start( {local, ?MODULE}, ?MODULE, [], []).
+ gen_server:start( {local, ?MODULE}, ?MODULE, [], []).
start_link() ->
- gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+ gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
stop() -> gen_server:cast(?MODULE, stop).
@@ -30,29 +30,29 @@ stop() -> gen_server:cast(?MODULE, stop).
%% ===================================================================
init([]) ->
- {ok, Port} = application:get_env(port),
- {ok, Socket} = gen_udp:open(Port, [binary, {active, once}]),
- { ok, #state{ socket = Socket } }.
+ {ok, Port} = application:get_env(port),
+ {ok, Socket} = gen_udp:open(Port, [binary, {active, once}]),
+ { ok, #state{ socket = Socket } }.
handle_call( _Msg, _From, State ) ->
- { reply, ok, State }.
+ { reply, ok, State }.
handle_cast( stop, State ) ->
- { stop, normal, State };
+ { stop, normal, State };
handle_cast( _Msg, State ) ->
- { stop, normal, State }.
+ { stop, normal, State }.
code_change(_OldVsn, State, _Extra) ->
- { ok, State }.
+ { ok, State }.
handle_info( {udp, Socket, IP, Port, Msg}, State ) ->
- spawn(bitturret_worker, handle, [{Socket, IP, Port}, Msg]),
- inet:setopts(State#state.socket, [{active, once}]),
- { noreply, State }.
+ spawn(bitturret_worker, handle, [{Socket, IP, Port}, Msg]),
+ inet:setopts(State#state.socket, [{active, once}]),
+ { noreply, State }.
terminate( _Reason, _State ) ->
- whatever.
+ whatever.
%% ===================================================================
%% Public API
View
6 apps/bitturret/src/bitturret_sup.erl
@@ -23,8 +23,8 @@ start_link() ->
%% ===================================================================
init([]) ->
- Children = [?CHILD(bitturret_handler, worker)],
+ Children = [?CHILD(bitturret_handler, worker)],
- RestartStrategy = {one_for_one, 0, 1},
+ RestartStrategy = {one_for_one, 0, 1},
- {ok, {RestartStrategy, Children}}.
+ {ok, {RestartStrategy, Children}}.
View
56 apps/bitturret/src/bitturret_worker.erl
@@ -4,37 +4,37 @@
handle(From, <<ConnectionID:64/big, 0:32/big, TransactionID:32/big>>) ->
- error_logger:info_msg("Connection Request"),
- error_logger:info_msg("C: ~p A: ~p T: ~p~n", [ConnectionID, 0, TransactionID]),
- Response = <<0:32/big, TransactionID:32/big, ConnectionID:64/big>>,
- send_response( From, Response );
+ error_logger:info_msg("Connection Request"),
+ error_logger:info_msg("C: ~p A: ~p T: ~p~n", [ConnectionID, 0, TransactionID]),
+ Response = <<0:32/big, TransactionID:32/big, ConnectionID:64/big>>,
+ send_response( From, Response );
handle(From,
- <<
- ConnectionID:64/big,
- Action:32/big,
- TransactionID:32/big,
- InfoHash:160/bitstring,
- PeerID:160/bitstring,
- Downloaded:64/big,
- Left:64/big,
- Uploaded:64/big,
- Event:32/big,
- IPaddress:32/big,
- Key:32/big,
- NumWait:32/big,
- Port:16/big
- >>) ->
-
- error_logger:info_msg("Announce Request"),
- error_logger:info_msg("Info Hash: ~p~n", [InfoHash]),
-
- Peers = << <<IP:32/big,Port:16/big>> || {IP,Port} <- [{3261057657, 51413}] >>,
- Response = <<1:32/big, TransactionID:32/big, 60:32/big, 10:32/big, 5:32/big, Peers/binary>>,
- send_response(From, Response);
+ <<
+ ConnectionID:64/big,
+ Action:32/big,
+ TransactionID:32/big,
+ InfoHash:160/bitstring,
+ PeerID:160/bitstring,
+ Downloaded:64/big,
+ Left:64/big,
+ Uploaded:64/big,
+ Event:32/big,
+ IPaddress:32/big,
+ Key:32/big,
+ NumWait:32/big,
+ Port:16/big
+ >>) ->
+
+ error_logger:info_msg("Announce Request"),
+ error_logger:info_msg("Info Hash: ~p~n", [InfoHash]),
+
+ Peers = << <<IP:32/big,Port:16/big>> || {IP,Port} <- [{3261057657, 51413}] >>,
+ Response = <<1:32/big, TransactionID:32/big, 60:32/big, 10:32/big, 5:32/big, Peers/binary>>,
+ send_response(From, Response);
handle(From, Msg) ->
- error_logger:info_msg("Something else: ~p~n", [Msg]).
+ error_logger:info_msg("Something else: ~p~n", [Msg]).
send_response({Socket, IP, Port}, Response) ->
- gen_udp:send(Socket, IP, Port, Response).
+ gen_udp:send(Socket, IP, Port, Response).
Please sign in to comment.
Something went wrong with that request. Please try again.