diff --git a/src/core/device/hb_device.erl b/src/core/device/hb_device.erl index df9ea5aa9..3abd15ddf 100644 --- a/src/core/device/hb_device.erl +++ b/src/core/device/hb_device.erl @@ -132,6 +132,14 @@ message_to_fun(Dev, Msg, Key, Opts) -> %% internal module-loading path. message_to_device(Msg, Opts) -> DevID = hb_maps:get(<<"device">>, Msg, ?DEFAULT_DEVICE, Opts), + case hb_opts:get(<<"admissible-devices">>, all, Opts) of + all -> ok; + DevIDs when is_list(DevIDs) -> + case lists:member(DevID, DevIDs) of + true -> ok; + false -> throw({error, {device_not_admissible, DevID}}) + end + end, case hb_device_load:reference(DevID, Opts) of {error, Reason} -> throw({error, {device_not_loadable, DevID, Reason}}); {ok, DevMod} -> DevMod diff --git a/src/preloaded/vm/dev_lua.erl b/src/preloaded/vm/dev_lua.erl index 18729c776..241d35221 100644 --- a/src/preloaded/vm/dev_lua.erl +++ b/src/preloaded/vm/dev_lua.erl @@ -807,7 +807,7 @@ ao_core_sandbox_test() -> <<"parameters">> => [], <<"device-sandbox">> => [<<"message@1.0">>] }, - ?assertMatch({error, _}, hb_ao:resolve(Base, <<"ao_relay">>, #{})), + ?assertMatch({error, _}, hb_ao:resolve(Base, <<"ao_meta">>, #{})), ?assertMatch({ok, _}, hb_ao:resolve(Base, <<"ao_resolve">>, #{})). %% @doc Run an AO-Core resolution from the Lua environment. diff --git a/test/test.lua b/test/test.lua index cae364585..35d6db692 100644 --- a/test/test.lua +++ b/test/test.lua @@ -39,10 +39,10 @@ function ao_resolve() return res end -function ao_relay() +function ao_meta() local status, res = ao.resolve({ - path = "/~relay@1.0/call?relay-path=http://localhost:10000/hello" + path = "/~meta@1.0/info" }) return res end