/*Send an auth error to peer because he sent a bad cookie.
* The auth error uses his cookie (not revealing ours).
* This is just like send_reg otherwise
*/
private void cookieError(OtpLocalNode local, Erlang.Atom cookie)
{
try
{
OtpOutputStream header = new OtpOutputStream(headerLen);
// preamble: 4 byte length + "passthrough" tag + version
header.write4BE(0); // reserve space for length
header.write1(passThrough);
header.write1(version);
header.write_tuple_head(4);
header.write_long((long)OtpMsg.Tag.regSendTag);
header.write_any(local.createPid()); // disposable pid
header.write_atom(cookie.atomValue()); // important: his cookie, not mine...
header.write_atom("auth");
// version for payload
header.write1(version);
// the payload
// the no_auth message (copied from Erlang) Don't change this (Erlang will crash)
// {$gen_cast, {print, "~n** Unauthorized cookie ~w **~n", [foo@aule]}}
Erlang.Object[] msg = new Erlang.Object[2];
Erlang.Object[] msgbody = new Erlang.Object[3];
msgbody[0] = new Erlang.Atom("print");
msgbody[1] = new Erlang.String("~n** Bad cookie sent to " + local + " **~n");
// Erlang will crash and burn if there is no third argument here...
msgbody[2] = new Erlang.List(); // empty list
msg[0] = new Erlang.Atom("$gen_cast");
msg[1] = new Erlang.Tuple(msgbody);
OtpOutputStream payload = new OtpOutputStream(new Erlang.Tuple(msg));
// fix up length in preamble
header.poke4BE(0, header.count() + payload.count() - 4);
try
{
do_send(header, payload);
}
catch (System.IO.IOException)
{
} // ignore
}
finally
{
close();
throw new OtpAuthException("Remote cookie not authorized: " + cookie.atomValue());
}
}