Exemple #1
0
        /// <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>
        private void cookieError(ErlLocalNode local, ErlAtom cookie)
        {
            var header = new ErlOutputStream(writeVersion: false, capacity: HEADER_LEN);

            // preamble: 4 byte length + "PASS_THROUGH" tag + version
            header.Write4BE(0); // reserve space for length
            header.Write1(PASS_THROUGH);
            header.Write1((byte)ErlExternalTag.Version);

            header.WriteTupleHead(4);
            header.WriteLong((long)ErlMsg.Tag.RegSend);
            header.WritePid(local.CreatePid()); // disposable pid
            header.WriteAtom(cookie);           // important: his cookie, not mine...
            header.WriteAtom("auth");

            // 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]}}

            var msg = ErlObject.Parse(
                "{'$gen_cast', {print, \"\n** Unauthorized cookie ~w **\n\", [" + local.NodeName.Value + "]}}");

            var payload = new ErlOutputStream(msg, writeVersion: true);

            // fix up length in preamble
            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);
            }
        }
Exemple #2
0
 /// <summary>
 /// Add a matching pattern to the collection
 /// </summary>
 /// <param name="pattern">Pattern to compile</param>
 /// <param name="func">Function to invoke on successful match</param>
 /// <returns>ID of the newly added pattern</returns>
 public int Add(string pattern, PatternMatchFunc func)
 {
     return(Add(ErlObject.Parse(pattern), func));
 }
Exemple #3
0
 public Pattern(int id, PatternMatchFunc b, string pattern, params object[] args)
 {
     ID = id; Func = b; Term = ErlObject.Parse(pattern, args);
 }
Exemple #4
0
 /// <summary>
 /// Add a matching pattern to the collection
 /// </summary>
 /// <typeparam name="TContext">Type of context passed to func</typeparam>
 /// <param name="context">Context passed to func</param>
 /// <param name="pattern">Pattern to compile</param>
 /// <param name="func">Function to invoke on successful match</param>
 /// <returns>ID of the newly added pattern</returns>
 public int Add <TContext>(TContext context, string pattern, PatternMatchFunc <TContext> func)
 {
     return(Add(context, ErlObject.Parse(pattern), func));
 }