From 63d85b9f7a275b3b2b5ce9f5ad69a13c06eac04b Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Mon, 6 Jan 2020 11:00:59 +0900 Subject: [PATCH] Fix peer mode queries and add help output --- zomp/etc/version.txt | 2 +- zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/Emakefile | 0 zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/LICENSE | 0 zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/ebin/zx.app | 2 +- .../zx/{0.6.0 => 0.6.1}/include/zx_logger.hrl | 0 zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/make_zx | 0 zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx.erl | 3 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_auth.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_conn.erl | 2 +- .../zx/{0.6.0 => 0.6.1}/src/zx_conn_sup.erl | 2 +- .../zx/{0.6.0 => 0.6.1}/src/zx_daemon.erl | 125 +++++++++--------- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_key.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_lib.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_local.erl | 21 ++- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_net.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_peer.erl | 5 +- .../zx/{0.6.0 => 0.6.1}/src/zx_peer_man.erl | 2 +- .../zx/{0.6.0 => 0.6.1}/src/zx_peer_sup.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_peers.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_proxy.erl | 3 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_sup.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_tty.erl | 2 +- .../zx/{0.6.0 => 0.6.1}/src/zx_userconf.erl | 2 +- .../otpr/zx/{0.6.0 => 0.6.1}/src/zx_zsp.erl | 2 +- .../zx/{0.6.0 => 0.6.1}/templates/Emakefile | 0 .../templates/boringlib/funfile.erl | 0 .../zx/{0.6.0 => 0.6.1}/templates/escript | 0 .../templates/example_server/appmod.erl | 0 .../templates/example_server/src/client.erl | 0 .../example_server/src/client_man.erl | 0 .../example_server/src/client_sup.erl | 0 .../templates/example_server/src/clients.erl | 0 .../templates/example_server/src/sup.erl | 0 .../zx/{0.6.0 => 0.6.1}/templates/gitignore | 0 .../templates/hellowx/appmod.erl | 0 .../templates/hellowx/src/con.erl | 0 .../templates/hellowx/src/gui.erl | 0 .../templates/hellowx/src/sup.erl | 0 .../templates/licenses/apache2.txt | 0 .../templates/licenses/bsd2.txt | 0 .../templates/licenses/bsd3.txt | 0 .../templates/licenses/cc0.txt | 0 .../templates/licenses/gpl3.txt | 0 .../templates/licenses/lgpl3.txt | 0 .../templates/licenses/mit.txt | 0 .../templates/licenses/mpl2.txt | 0 .../{0.6.0 => 0.6.1}/templates/simplecli.erl | 0 zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/zomp.meta | 2 +- 48 files changed, 102 insertions(+), 87 deletions(-) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/Emakefile (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/LICENSE (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/ebin/zx.app (93%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/include/zx_logger.hrl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/make_zx (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_auth.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_conn.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_conn_sup.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_daemon.erl (97%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_key.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_lib.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_local.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_net.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_peer.erl (98%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_peer_man.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_peer_sup.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_peers.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_proxy.erl (98%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_sup.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_tty.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_userconf.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/src/zx_zsp.erl (99%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/Emakefile (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/boringlib/funfile.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/escript (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/example_server/appmod.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/example_server/src/client.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/example_server/src/client_man.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/example_server/src/client_sup.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/example_server/src/clients.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/example_server/src/sup.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/gitignore (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/hellowx/appmod.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/hellowx/src/con.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/hellowx/src/gui.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/hellowx/src/sup.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/apache2.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/bsd2.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/bsd3.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/cc0.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/gpl3.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/lgpl3.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/mit.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/licenses/mpl2.txt (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/templates/simplecli.erl (100%) rename zomp/lib/otpr/zx/{0.6.0 => 0.6.1}/zomp.meta (91%) diff --git a/zomp/etc/version.txt b/zomp/etc/version.txt index a918a2a..ee6cdce 100644 --- a/zomp/etc/version.txt +++ b/zomp/etc/version.txt @@ -1 +1 @@ -0.6.0 +0.6.1 diff --git a/zomp/lib/otpr/zx/0.6.0/Emakefile b/zomp/lib/otpr/zx/0.6.1/Emakefile similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/Emakefile rename to zomp/lib/otpr/zx/0.6.1/Emakefile diff --git a/zomp/lib/otpr/zx/0.6.0/LICENSE b/zomp/lib/otpr/zx/0.6.1/LICENSE similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/LICENSE rename to zomp/lib/otpr/zx/0.6.1/LICENSE diff --git a/zomp/lib/otpr/zx/0.6.0/ebin/zx.app b/zomp/lib/otpr/zx/0.6.1/ebin/zx.app similarity index 93% rename from zomp/lib/otpr/zx/0.6.0/ebin/zx.app rename to zomp/lib/otpr/zx/0.6.1/ebin/zx.app index 9212844..2683b28 100644 --- a/zomp/lib/otpr/zx/0.6.0/ebin/zx.app +++ b/zomp/lib/otpr/zx/0.6.1/ebin/zx.app @@ -1,6 +1,6 @@ {application,zx, [{description,"An Erlang development tool and Zomp user client"}, - {vsn,"0.6.0"}, + {vsn,"0.6.1"}, {applications,[stdlib,kernel]}, {modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key, zx_lib,zx_local,zx_net,zx_peer,zx_peer_man, diff --git a/zomp/lib/otpr/zx/0.6.0/include/zx_logger.hrl b/zomp/lib/otpr/zx/0.6.1/include/zx_logger.hrl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/include/zx_logger.hrl rename to zomp/lib/otpr/zx/0.6.1/include/zx_logger.hrl diff --git a/zomp/lib/otpr/zx/0.6.0/make_zx b/zomp/lib/otpr/zx/0.6.1/make_zx similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/make_zx rename to zomp/lib/otpr/zx/0.6.1/make_zx diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx.erl b/zomp/lib/otpr/zx/0.6.1/src/zx.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx.erl index 96ba9c2..2fec63e 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx.erl @@ -24,7 +24,7 @@ %%% @end -module(zx). --vsn("0.6.0"). +-vsn("0.6.1"). -behavior(application). -author("Craig Everett "). -copyright("Craig Everett "). @@ -899,6 +899,7 @@ usage_user() -> " zx list realms~n" " zx list packages Realm~n" " zx list versions PackageID~n" + " zx list [gui | cli | app | lib]~n" " zx latest PackageID~n" " zx search Tag~n" " zx describe Package~n" diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_auth.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_auth.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_auth.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_auth.erl index 3872f5a..955da6f 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_auth.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_auth.erl @@ -9,7 +9,7 @@ %%% @end -module(zx_auth). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_conn.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_conn.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_conn.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_conn.erl index a4126c6..0cebf5b 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_conn.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_conn.erl @@ -7,7 +7,7 @@ %%% @end -module(zx_conn). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_conn_sup.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_conn_sup.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_conn_sup.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_conn_sup.erl index a6e2121..3949765 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_conn_sup.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_conn_sup.erl @@ -5,7 +5,7 @@ %%% @end -module(zx_conn_sup). --vsn("0.6.0"). +-vsn("0.6.1"). -behavior(supervisor). -author("Craig Everett "). -copyright("Craig Everett "). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_daemon.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_daemon.erl similarity index 97% rename from zomp/lib/otpr/zx/0.6.0/src/zx_daemon.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_daemon.erl index f39665d..f4dae41 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_daemon.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_daemon.erl @@ -138,7 +138,7 @@ %%% @end -module(zx_daemon). --vsn("0.6.0"). +-vsn("0.6.1"). -behavior(gen_server). -author("Craig Everett "). -copyright("Craig Everett "). @@ -147,8 +147,8 @@ -export([zomp_mode/0]). -export([pass_meta/3, argv/0, subscribe/1, unsubscribe/1, - list/0, list/1, list/2, list/3, list_type/2, latest/1, - describe/1, provides/2, list_deps/1, search/2, + list/0, list/1, list/2, list/3, list_type/1, latest/1, + describe/1, provides/2, list_deps/1, search/1, list_sysops/1, fetch/1, install/1, build/1, wait_result/1, wait_results/1]). @@ -187,7 +187,7 @@ dropped = maps:new() :: requests(), timer = none :: none | reference(), mx = mx_new() :: monitor_index(), - cx = new_cx() :: conn_index()}). + cx = offline :: conn_index()}). -record(conf, {realms = zx_lib:list_realms() :: [zx:realm()], @@ -233,7 +233,7 @@ | {request, pid(), id(), action()}. -type requests() :: #{id() := {pid(), action()}}. -type monitor_index() :: #{pid() := {reference(), category()}}. --type conn_index() :: #cx{} | zomp | proxy. +-type conn_index() :: #cx{} | zomp | proxied | offline. -type realm_meta() :: #rmeta{}. -type connection() :: #conn{}. -type category() :: {Reqs :: [id()], Subs :: [zx:package()]} @@ -446,12 +446,11 @@ list(Realm, Name, Version) -> request({list, Realm, Name, Version}). --spec list_type(Realm, Type) -> {ok, RequestID} - when Realm :: zx:realm(), - Type :: zx:package_type(), +-spec list_type(Target) -> {ok, RequestID} + when Target :: {zx:realm(), zx:package_type()}, RequestID :: term(). -list_type(Realm, Type) -> +list_type({Realm, Type}) -> true = zx_lib:valid_lower0_9(Realm), request({list_type, Realm, Type}). @@ -499,12 +498,11 @@ provides(Realm, Module) -> request({provides, Realm, Module}). --spec search(Realm, String) -> {ok, RequestID} - when Realm :: zx:realm(), - String :: string(), +-spec search(Target) -> {ok, RequestID} + when Target :: {zx:realm(), string()}, RequestID :: integer(). -search(Realm, String) -> +search({Realm, String}) -> request({search, Realm, String}). @@ -751,7 +749,7 @@ start_link() -> init(none) -> State = #s{}, - {ok, cx_load(State)}. + {ok, State}. -spec connect() -> ok. @@ -957,8 +955,11 @@ terminate(_, _) -> ok. do_idle(#s{id = ID, cx = zomp}) -> ok = log(info, "Idling as zomp with ID: ~p.", [ID]), ok = retire(ID); -do_idle(#s{cx = proxy}) -> - ok = log(info, "Idling as proxy."), +do_idle(#s{cx = offline}) -> + ok = log(info, "Idling while offline."), + ok; +do_idle(#s{cx = proxied}) -> + ok = log(info, "Idling while proxied."), ok; do_idle(#s{id = ID, cx = CX}) -> ok = log(info, "Idling as prime with ID: ~p.", [ID]), @@ -1035,10 +1036,12 @@ do_unsubscribe(Pid, Package, State = #s{actions = Actions, mx = MX}) -> %% @private %% Enqueue requests and update relevant index. -do_request(Requestor, Action, State = #s{id = ID, cx = proxy}) -> +do_request(Requestor, Action, State = #s{id = ID, cx = proxied}) -> Result = zx_proxy:request(Action), Requestor ! {result, ID, Result}, State; +do_request(_, _, #s{cx = offline}) -> + throw("Trying to perform request while offline. Impossible! I am ded."); do_request(Requestor, Action, State = #s{id = ID, actions = Actions, mx = MX}) -> NewActions = [{request, Requestor, ID, Action} | Actions], NewMX = mx_add_monitor(Requestor, {requestor, ID}, MX), @@ -1057,9 +1060,12 @@ do_request(Requestor, Action, State = #s{id = ID, actions = Actions, mx = MX}) - do_report(Conn, Report, State = #s{cx = zomp}) -> ok = log(warning, "Zomp mode: Discarding report ~tp ~200tp", [Conn, Report]), State; -do_report(Conn, Report, State = #s{cx = proxy}) -> +do_report(Conn, Report, State = #s{cx = proxied}) -> ok = log(warning, "Proxied: Discarding report ~tp ~200tp", [Conn, Report]), State; +do_report(Conn, Report, State = #s{cx = offline}) -> + ok = log(warning, "Offline: Discarding report ~tp ~200tp", [Conn, Report]), + State; do_report(Conn, {connected, Realms}, State = #s{mx = MX, cx = CX}) -> {NewMX, NewCX} = case cx_connected(Realms, Conn, CX) of @@ -1154,21 +1160,24 @@ dequeue(Pending) -> connect(State = #s{cx = zomp}) -> State; -connect(State) -> +connect(State = #s{cx = offline}) -> LockFile = lockfile(), case file:read_file(LockFile) of {ok, PS} -> Port = binary_to_integer(string:trim(PS)), + ok = log(info, "Connecting to local proxy."), proxy_connect(Port, State); {error, enoent} -> - remote_connect(State) - end. + remote_connect(cx_load(State)) + end; +connect(State) -> + remote_connect(State). proxy_connect(Port, State) -> case zx_proxy:connect(Port) of - ok -> State#s{cx = proxy}; - error -> remote_connect(State) + ok -> State#s{cx = proxied}; + error -> remote_connect(cx_load(State)) end. @@ -1191,7 +1200,7 @@ init_connections([], State) -> ensure_connections(State = #s{cx = zomp}) -> State; -ensure_connections(State = #s{cx = proxy}) -> +ensure_connections(State = #s{cx = proxied}) -> State; ensure_connections(State = #s{conf = Conf, mx = MX, cx = CX}) -> #conf{realms = Realms, managed = Managed} = Conf, @@ -1212,14 +1221,20 @@ ensure_connections(State = #s{conf = Conf, mx = MX, cx = CX}) -> -spec wipe_connections(state()) -> ok. -wipe_connections(State = #s{cx = proxy}) -> +wipe_connections(State = #s{cx = proxied}) -> ok = log(warning, "Proxied: No connections to wipe."), State; +wipe_connections(State = #s{cx = offline}) -> + ok = log(warning, "Offline: No connections to wipe."), + State; +wipe_connections(State = #s{cx = zomp}) -> + ok = log(warning, "Zomp: No connections to wipe."), + State; wipe_connections(State = #s{mx = MX, cx = CX}) -> - {Pids, NewCX} = cx_wipe(CX), + Pids = cx_wipe(CX), Remove = fun(P, M) -> mx_del_monitor(P, conn, M) end, NewMX = lists:foldl(Remove, MX, Pids), - State#s{mx = NewMX, cx = NewCX}. + State#s{mx = NewMX, cx = offline}. -spec do_result(ID, Result, State) -> NewState @@ -1321,7 +1336,7 @@ do_notify(Conn, Channel, Message, #s{cx = CX}) -> %% This function must iterate as far as it can into the request queue, adding response %% entries to the pending response structure as it goes. -eval_queue(State = #s{cx = proxy}) -> +eval_queue(State = #s{cx = proxied}) -> State; eval_queue(State = #s{actions = Actions}) -> InOrder = lists:reverse(Actions), @@ -1390,7 +1405,8 @@ local_request(R, {describe, N, V}) -> zomp_realm:describe(R, {N, V}); local_request(R, {provides, M}) -> zomp_realm:provides(R, M); local_request(R, {search, S}) -> zomp_realm:search(R, S); local_request(R, {list_deps, N, V}) -> zomp_realm:list_deps(R, {N, V}); -local_request(R, {list_sysops}) -> zomp_realm:list_sysops(R). +local_request(R, {list_sysops}) -> zomp_realm:list_sysops(R); +local_request(R, {list_type, T}) -> zomp_realm:list_type(R, T). remote_dispatch([], State) -> @@ -2014,23 +2030,6 @@ do_drop_realm(Realm, State) -> do_abdicate(Realm, State). --spec become_proxy(State) -> NewState - when State :: state(), - NewState :: state(). - -become_proxy(State = #s{cx = zomp}) -> - ok = log(warning, "Already set as zomp node."), - State; -become_proxy(State = #s{cx = proxy}) -> - {ok, Port} = zx_peer_man:listen(), - ok = write_lockfile(Port), - {ok, ID} = zx_proxy:youre_fired(), - State#s{id = ID, cx = zomp}; -become_proxy(State) -> - ok = log(warning, "Already acting proxy."), - State. - - -spec become_zomp_node(State) -> NewState when State :: state(), NewState :: state(). @@ -2038,9 +2037,13 @@ become_proxy(State) -> become_zomp_node(State = #s{cx = zomp}) -> ok = log(warning, "Already set as zomp node."), State; -become_zomp_node(State = #s{cx = proxy}) -> - NewState = become_proxy(State), - NewState#s{cx = zomp}; +become_zomp_node(State = #s{cx = offline}) -> + State#s{cx = zomp}; +become_zomp_node(State = #s{cx = proxied}) -> + {ok, Port} = zx_peer_man:listen(), + ok = write_lockfile(Port), + {ok, ID} = zx_proxy:youre_fired(), + State#s{id = ID, cx = zomp}; become_zomp_node(State) -> NewState = wipe_connections(State), NewState#s{cx = zomp}. @@ -2178,10 +2181,6 @@ mx_drop_monitor(Pid, MX) -> %%% %%% Return values often carry some status information with them. --spec new_cx() -> conn_index(). - -new_cx() -> #cx{}. - -spec cx_load(state()) -> state(). %% @private @@ -2320,9 +2319,11 @@ cx_hosts_cache() -> cx_realms(#cx{realms = Realms}) -> maps:keys(Realms); +cx_realms(offline) -> + zx_lib:list_realms(); cx_realms(zomp) -> zx_lib:list_realms(); -cx_realms(proxy) -> +cx_realms(proxied) -> {ok, Realms} = zx_proxy:request(list), Realms. @@ -2330,12 +2331,12 @@ cx_realms(proxy) -> -spec cx_mirrors(CX) -> Result when CX :: conn_index(), Result :: {ok, [zx:host()]} - | {error, zomp}. + | {error, offline | zomp | proxied}. cx_mirrors(#cx{mirrors = Mirrors}) -> {ok, queue:to_list(Mirrors)}; -cx_mirrors(zomp) -> - {error, zomp}. +cx_mirrors(Status) -> + {error, Status}. -spec cx_check_service(Realms, CX) -> Result @@ -2453,14 +2454,14 @@ cx_redirect([], CX) -> CX. --spec cx_wipe(CX) -> ok - when CX :: conn_index(). +-spec cx_wipe(CX) -> Pids + when CX :: conn_index(), + Pids :: [pid()]. -cx_wipe(CX = #cx{conns = Conns, mirrors = Mirrors}) -> +cx_wipe(#cx{conns = Conns}) -> Pids = [P || #conn{pid = P} <- Conns], ok = lists:foreach(fun zx_conn:retire/1, Pids), - NewCX = CX#cx{conns = [], hosts = Mirrors}, - {Pids, NewCX}. + Pids. -spec cx_disconnected(Conn, CX) -> {Requests, Subs, NewCX} diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_key.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_key.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_key.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_key.erl index fe8a2e6..ff281b6 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_key.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_key.erl @@ -8,7 +8,7 @@ %%% @end -module(zx_key). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_lib.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_lib.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_lib.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_lib.erl index e723f55..c250462 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_lib.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_lib.erl @@ -10,7 +10,7 @@ %%% @end -module(zx_lib). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_local.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_local.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_local.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_local.erl index 722fbd2..f4ce049 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_local.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_local.erl @@ -6,7 +6,7 @@ %%% @end -module(zx_local). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). @@ -757,16 +757,27 @@ list_type(Type) -> Realms = zx_lib:list_realms(), MakeRequest = fun(Realm) -> - {ok, ID} = zx_daemon:list_type(Realm, Type), + {ok, ID} = zx_daemon:list_type({Realm, Type}), ID end, Index = [{MakeRequest(R), R} || R <- Realms], IDs = [element(1, I) || I <- Index], case zx_daemon:wait_results(IDs) of - {ok, Results} -> print_multirealm(lists:sort(Index), lists:sort(Results)); - Error -> Error + {ok, Results} -> + Packages = scrub_errors(lists:sort(Index), lists:sort(Results), []), + lists:foreach(fun print_packages/1, lists:sort(Packages)); + Error -> + Error end. +scrub_errors([{ID, _} | Index], [{ID, {ok, PackageID}} | Results], Acc) -> + scrub_errors(Index, Results, [PackageID | Acc]); +scrub_errors([{ID, Realm} | Index], [{ID, Error} | Results], Acc) -> + ok = tell(warning, "Received weird result from realm ~tp: ~tp", [Realm, Error]), + scrub_errors(Index, Results, Acc); +scrub_errors([], [], Acc) -> + lists:append(Acc). + -spec latest(PackageString :: string()) -> zx:outcome(). @@ -845,7 +856,7 @@ search(String) -> Realms = zx_lib:list_realms(), MakeRequest = fun(Realm) -> - {ok, ID} = zx_daemon:search(Realm, String), + {ok, ID} = zx_daemon:search({Realm, String}), ID end, Index = [{MakeRequest(R), R} || R <- Realms], diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_net.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_net.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_net.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_net.erl index d3233fa..ab9cb4e 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_net.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_net.erl @@ -5,7 +5,7 @@ %%% @end -module(zx_net). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_peer.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_peer.erl similarity index 98% rename from zomp/lib/otpr/zx/0.6.0/src/zx_peer.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_peer.erl index 77ed3f4..9df6f8b 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_peer.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_peer.erl @@ -8,7 +8,7 @@ %%% @end -module(zx_peer). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). @@ -181,7 +181,8 @@ handle_message(<>) -> 24 -> list_keys(Payload); 25 -> zx_daemon:takeover(Payload); 26 -> zx_daemon:abdicate(Payload); - 27 -> zx_daemon:drop_realm(Payload) + 27 -> zx_daemon:drop_realm(Payload); + 28 -> deferred(fun zx_daemon:list_type/1, Payload) end, pack(Result). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_peer_man.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_peer_man.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_peer_man.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_peer_man.erl index 7aba59b..dd0a14d 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_peer_man.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_peer_man.erl @@ -9,7 +9,7 @@ %%% @end -module(zx_peer_man). --vsn("0.6.0"). +-vsn("0.6.1"). -behavior(gen_server). -author("Craig Everett "). -copyright("Craig Everett "). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_peer_sup.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_peer_sup.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_peer_sup.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_peer_sup.erl index 73a24a3..b342221 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_peer_sup.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_peer_sup.erl @@ -6,7 +6,7 @@ %%% @end -module(zx_peer_sup). --vsn("0.6.0"). +-vsn("0.6.1"). -behaviour(supervisor). -author("Craig Everett "). -copyright("Craig Everett "). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_peers.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_peers.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_peers.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_peers.erl index de7a368..9211aec 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_peers.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_peers.erl @@ -10,7 +10,7 @@ %%% @end -module(zx_peers). --vsn("0.6.0"). +-vsn("0.6.1"). -behavior(supervisor). -author("Craig Everett "). -copyright("Craig Everett "). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_proxy.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_proxy.erl similarity index 98% rename from zomp/lib/otpr/zx/0.6.0/src/zx_proxy.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_proxy.erl index 16adc7b..f26366e 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_proxy.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_proxy.erl @@ -5,7 +5,7 @@ %%% @end -module(zx_proxy). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). @@ -167,6 +167,7 @@ dispatch(Socket, Action) -> {takeover, R} -> make_query(Socket, 25, R); {abdicate, R} -> make_query(Socket, 26, R); {drop_realm, R} -> make_query(Socket, 27, R); + {list_type, R, T} -> make_query(Socket, 28, {R, T}); Unexpected -> Message = "Received unexpected request action. Action: ~200tp", ok = log(warning, Message, [Unexpected]), diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_sup.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_sup.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_sup.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_sup.erl index 84d31d9..03188e9 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_sup.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_sup.erl @@ -5,7 +5,7 @@ %%% @end -module(zx_sup). --vsn("0.6.0"). +-vsn("0.6.1"). -behavior(supervisor). -author("Craig Everett "). -copyright("Craig Everett "). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_tty.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_tty.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_tty.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_tty.erl index 040feaf..b7297c9 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_tty.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_tty.erl @@ -6,7 +6,7 @@ %%% @end -module(zx_tty). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_userconf.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_userconf.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_userconf.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_userconf.erl index 8dce814..b22216e 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_userconf.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_userconf.erl @@ -5,7 +5,7 @@ %%% @end -module(zx_userconf). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/src/zx_zsp.erl b/zomp/lib/otpr/zx/0.6.1/src/zx_zsp.erl similarity index 99% rename from zomp/lib/otpr/zx/0.6.0/src/zx_zsp.erl rename to zomp/lib/otpr/zx/0.6.1/src/zx_zsp.erl index 8bbf707..b47efe1 100644 --- a/zomp/lib/otpr/zx/0.6.0/src/zx_zsp.erl +++ b/zomp/lib/otpr/zx/0.6.1/src/zx_zsp.erl @@ -7,7 +7,7 @@ %%% @end -module(zx_zsp). --vsn("0.6.0"). +-vsn("0.6.1"). -author("Craig Everett "). -copyright("Craig Everett "). -license("GPL-3.0"). diff --git a/zomp/lib/otpr/zx/0.6.0/templates/Emakefile b/zomp/lib/otpr/zx/0.6.1/templates/Emakefile similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/Emakefile rename to zomp/lib/otpr/zx/0.6.1/templates/Emakefile diff --git a/zomp/lib/otpr/zx/0.6.0/templates/boringlib/funfile.erl b/zomp/lib/otpr/zx/0.6.1/templates/boringlib/funfile.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/boringlib/funfile.erl rename to zomp/lib/otpr/zx/0.6.1/templates/boringlib/funfile.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/escript b/zomp/lib/otpr/zx/0.6.1/templates/escript similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/escript rename to zomp/lib/otpr/zx/0.6.1/templates/escript diff --git a/zomp/lib/otpr/zx/0.6.0/templates/example_server/appmod.erl b/zomp/lib/otpr/zx/0.6.1/templates/example_server/appmod.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/example_server/appmod.erl rename to zomp/lib/otpr/zx/0.6.1/templates/example_server/appmod.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/example_server/src/client.erl b/zomp/lib/otpr/zx/0.6.1/templates/example_server/src/client.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/example_server/src/client.erl rename to zomp/lib/otpr/zx/0.6.1/templates/example_server/src/client.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/example_server/src/client_man.erl b/zomp/lib/otpr/zx/0.6.1/templates/example_server/src/client_man.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/example_server/src/client_man.erl rename to zomp/lib/otpr/zx/0.6.1/templates/example_server/src/client_man.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/example_server/src/client_sup.erl b/zomp/lib/otpr/zx/0.6.1/templates/example_server/src/client_sup.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/example_server/src/client_sup.erl rename to zomp/lib/otpr/zx/0.6.1/templates/example_server/src/client_sup.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/example_server/src/clients.erl b/zomp/lib/otpr/zx/0.6.1/templates/example_server/src/clients.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/example_server/src/clients.erl rename to zomp/lib/otpr/zx/0.6.1/templates/example_server/src/clients.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/example_server/src/sup.erl b/zomp/lib/otpr/zx/0.6.1/templates/example_server/src/sup.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/example_server/src/sup.erl rename to zomp/lib/otpr/zx/0.6.1/templates/example_server/src/sup.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/gitignore b/zomp/lib/otpr/zx/0.6.1/templates/gitignore similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/gitignore rename to zomp/lib/otpr/zx/0.6.1/templates/gitignore diff --git a/zomp/lib/otpr/zx/0.6.0/templates/hellowx/appmod.erl b/zomp/lib/otpr/zx/0.6.1/templates/hellowx/appmod.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/hellowx/appmod.erl rename to zomp/lib/otpr/zx/0.6.1/templates/hellowx/appmod.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/hellowx/src/con.erl b/zomp/lib/otpr/zx/0.6.1/templates/hellowx/src/con.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/hellowx/src/con.erl rename to zomp/lib/otpr/zx/0.6.1/templates/hellowx/src/con.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/hellowx/src/gui.erl b/zomp/lib/otpr/zx/0.6.1/templates/hellowx/src/gui.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/hellowx/src/gui.erl rename to zomp/lib/otpr/zx/0.6.1/templates/hellowx/src/gui.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/hellowx/src/sup.erl b/zomp/lib/otpr/zx/0.6.1/templates/hellowx/src/sup.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/hellowx/src/sup.erl rename to zomp/lib/otpr/zx/0.6.1/templates/hellowx/src/sup.erl diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/apache2.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/apache2.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/apache2.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/apache2.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/bsd2.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/bsd2.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/bsd2.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/bsd2.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/bsd3.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/bsd3.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/bsd3.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/bsd3.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/cc0.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/cc0.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/cc0.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/cc0.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/gpl3.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/gpl3.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/gpl3.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/gpl3.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/lgpl3.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/lgpl3.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/lgpl3.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/lgpl3.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/mit.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/mit.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/mit.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/mit.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/licenses/mpl2.txt b/zomp/lib/otpr/zx/0.6.1/templates/licenses/mpl2.txt similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/licenses/mpl2.txt rename to zomp/lib/otpr/zx/0.6.1/templates/licenses/mpl2.txt diff --git a/zomp/lib/otpr/zx/0.6.0/templates/simplecli.erl b/zomp/lib/otpr/zx/0.6.1/templates/simplecli.erl similarity index 100% rename from zomp/lib/otpr/zx/0.6.0/templates/simplecli.erl rename to zomp/lib/otpr/zx/0.6.1/templates/simplecli.erl diff --git a/zomp/lib/otpr/zx/0.6.0/zomp.meta b/zomp/lib/otpr/zx/0.6.1/zomp.meta similarity index 91% rename from zomp/lib/otpr/zx/0.6.0/zomp.meta rename to zomp/lib/otpr/zx/0.6.1/zomp.meta index 80885f4..7f115ee 100644 --- a/zomp/lib/otpr/zx/0.6.0/zomp.meta +++ b/zomp/lib/otpr/zx/0.6.1/zomp.meta @@ -8,7 +8,7 @@ {license,"MIT"}. {modules,[]}. {name,"zx"}. -{package_id,{"otpr","zx",{0,6,0}}}. +{package_id,{"otpr","zx",{0,6,1}}}. {prefix,"zx_"}. {repo_url,"https://gitlab.com/zxq9/zx"}. {tags,["tools","package manager","erlang"]}.