示例#1
0
            public I2NPHeader16(I2NPMessage msg)
                : this(msg, GenerateMessageId())
            {
#if DEBUG
                DebugCheckMessageCreation(MessageRef);
#endif
            }
示例#2
0
            public I2NPHeader5(I2NPMessage msg) : base(msg.Header5Buf)
            {
                MessageRef = msg;

                MessageType = msg.MessageType;
                Expiration  = I2PDate.DefaultI2NPExpiration();
#if DEBUG
                DebugCheckMessageCreation(MessageRef);
#endif
            }
示例#3
0
        protected static void DebugCheckMessageCreation( I2NPMessage msg )
        {
            if ( msg.Header16AndPayloadBuf == null )
            {
                throw new NotImplementedException( "I2NPHeader16: '" + msg.GetType().Name + "' failed to set up a memory buffer for Header16!" );
            }

            if ( !object.ReferenceEquals( msg.Payload.BaseArray, msg.Header16AndPayloadBuf.BaseArray )
                || msg.Payload.BaseArrayOffset != 16 + msg.Header16AndPayloadBuf.BaseArrayOffset )
            {
                throw new NotImplementedException( "I2NPHeader16: '" + msg.GetType().Name + "' created wrong size of buffer for Header16!" );
            }
        }
示例#4
0
            public I2NPHeader16(I2NPMessage msg, uint messageid) : base(msg.Header16Buf)
            {
                MessageRef = msg;

                MessageType = msg.MessageType;
                Expiration  = I2PDate.DefaultI2NPExpiration();
                MessageId   = messageid;

                PayloadLength = (ushort)msg.Payload.Length;

                var s = I2PHashSHA256.GetHash(msg.Payload);

                PayloadChecksum = s[0];
#if DEBUG
                DebugCheckMessageCreation(MessageRef);
#endif
            }
示例#5
0
            public static BufLen ToBufLen(I2NPMessage msg)
            {
                var hdr = new I2NPHeader5(msg);

                return(new BufLen(hdr.ToByteArray()));
            }
示例#6
0
            public static void Write(BufRefStream dest, I2NPMessage msg)
            {
                var inst = new I2NPHeader16(msg);

                inst.Write(dest);
            }
示例#7
0
            public static void Write(List <byte> dest, I2NPMessage msg)
            {
                var inst = new I2NPHeader16(msg);

                inst.Write(dest);
            }