Source/NFX.Erlang/Connect/ErlConnection.cs
/// <summary>
/// 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
/// </summary>
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
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(ErlLocalNode local, ErlAtom cookie)
    {
      var header = new ErlOutputStream(writeVersion: false, capacity: HEADER_LEN);
      header.Write4BE(0); 
      header.Write1(PASS_THROUGH);
      header.Write1((byte)ErlExternalTag.Version);
      header.WriteTupleHead(4);
      header.WriteLong((long)ErlMsg.Tag.RegSend);
      header.WritePid(local.CreatePid()); 
      header.WriteAtom(cookie); 
      header.WriteAtom("auth");
      var msg = ErlObject.Parse(
          "{'$gen_cast', {print, \"\n** Unauthorized cookie ~w **\n\", [" + local.NodeName.Value + "]}}");
      var payload = new ErlOutputStream(msg, writeVersion: true);
      header.Poke4BE(0, (int)(header.Length + payload.Length - 4));
      try
      {
        DoSend(header, payload);
      }
      catch (Exception e)
      {
        Close();
        throw new ErlException(StringConsts.ERL_CONN_UNAUTH_COOKIE_ERROR.Args(cookie.Value), e);
      }
    }
private void cookieError ( ErlLocalNode local , ErlAtom cookie ) { var header = new ErlOutputStream ( writeVersion : false , capacity : HEADER_LEN ) ; header . Write4BE ( 0 ) ; header . Write1 ( PASS_THROUGH ) ; header . Write1 ( ( byte ) ErlExternalTag . Version ) ; header . WriteTupleHead ( 4 ) ; header . WriteLong ( ( long ) ErlMsg . Tag . RegSend ) ; header . WritePid ( local . CreatePid ( ) ) ; header . WriteAtom ( cookie ) ; header . WriteAtom ( " " ) ; var msg = ErlObject . Parse ( " \" \n \n \" " + local . NodeName . Value + " " ) ; var payload = new ErlOutputStream ( msg , writeVersion : true ) ; header . Poke4BE ( 0 , ( int ) ( header . Length + payload . Length - 4 ) ) ; try { DoSend ( header , payload ) ; } catch ( Exception e ) { Close ( ) ; throw new ErlException ( StringConsts . ERL_CONN_UNAUTH_COOKIE_ERROR . Args ( cookie . Value ) , e ) ; } }
Send an auth error to peer because he sent a bad cookie
The auth error uses his cookie (not revealing ours).
Send an auth error to peer because he sent a bad cookie The auth error uses his cookie ( not revealing ours ) .
// preamble: 4 byte length + "PASS_THROUGH" tag + version // reserve space for length // disposable pid // important: his cookie, not mine... // version for payload written later by the payload stream //header.Write1((byte)ErlExternalTag.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]}} // fix up length in preamble
local
ErlLocalNode
cookie
ErlAtom