3 ms·
Sure: On a erlang shell in node A, do: register('test', self()). receive F -> ok end. (this gives the shell a registered name, and then waits for a mes
by toast0 7y ago
Sure:
On a erlang shell in node A, do:
register('test', self()).
receive F -> ok end.
(this gives the shell a registered name, and then waits for a message)
On a debug shell on node A do:
AddrFactory = fun (X) -> fun (Y) -> Y + X end end.
{test, NodeA} ! AddrFactory(5).
Then, back on node A, do
F(10).
And you'll get 15
For more fun, you could have node A send the value to go into the closure, etc.
NodeA is something like 'demo@hosta.example.org'
NodeA would be started with something like erl -name demo@hosta.example.org -setcookie demo
and NodeB started like erl -name demo@hostb.example.org -setcookie demo
- OskarS 7y agoThat is extremely cool.
- dnautics 7y agoIt's also crazy insecure, so you shouldn't use this sort of stuff unless you really know what you're doing and you have full control over the inputs and outputs, that includes owning your network in depth. I don't want to discourage you from using erlang and Elixir, because the beam is amazing, plenty of very lucrative companies (like bet365) do, just, be aware of things you might versus might not run in an actual prod situation.
- toast0 7y agoI mean, it's not that it's crazy insecure. It's that the security model is totally different. In distributed erlang, access to any node is effectively access to all of the nodes; it's best to consider the distributed system as one computer from a security point of view. Do not run distributed Erlang with nodes you don't trust. Do not run distributed Erlang on a network you don't trust (VPN/TLS can help).
- dnautics 7y agowell specfically `binary_to_term` on arbitrary untrusted data is insecure, but you could of course pass `[safe]` in. Just, read the docs and heed the warnings.