Display connection specific cookies in Erlang

前端 未结 2 525
既然无缘
既然无缘 2021-01-21 09:23

When setting a cookie on a node with erlang:set_cookie/2 it is possible to set different cookies for different nodes. Is there any way to display, which cookie is s

相关标签:
2条回答
  • 2021-01-21 10:14

    You have to run the get_cookie/0 function on NodeB to get the name for that node. Simple solution is to do (on NodeA):

    rpc:call(NodeB, erlang, get_cookie, []).
    

    after you have connected the nodes.

    Doing the erlang:set_cookie(NodeB, bar) call on NodeA just makes it possible for NodeA/NodeB to connect to each other, they still have their original cookies.

    But to be able to connect to the other node you must already know the cookie for that node :)

    0 讨论(0)
  • 2021-01-21 10:21

    It doesn't seem to be documented, but auth:get_cookie/1 does what you want. For your case, you can call auth:get_cookie(NodeB) on NodeA.

    0 讨论(0)
提交回复
热议问题