示例#1
0
 public LocalDrpPeer(DrpPeerEngine engine, LocalDrpPeerConfiguration configuration, IDrpRegisteredPeerApp drpPeerApp)
 {
     Engine         = engine;
     _configuration = configuration;
     _drpPeerApp    = drpPeerApp;
     engine.Configuration.VisionChannel?.RegisterVisibleModule(engine.Configuration.VisionChannelSourceId, this.ToString(), this);
 }
示例#2
0
 public Logger(DrpPeerEngine engine, IVisiblePeer localPeer, object req, string moduleName)
 {
     Engine                 = engine;
     _visionChannel         = engine.Configuration.VisionChannel;
     _visionChannelSourceId = engine.Configuration.VisionChannelSourceId;
     _localPeer             = localPeer;
     _req       = req;
     ModuleName = moduleName;
 }
示例#3
0
 public SentRequest(DrpPeerEngine engine, Logger logger, IPEndPoint destinationEndpoint, ConnectionToNeighbor destinationNeighborNullable, byte[] requestUdpData,
                    RequestP2pSequenceNumber16 sentReqP2pSeq16, LowLevelUdpResponseScanner ack1Scanner)
 {
     _destinationEndpoint = destinationEndpoint;
     _logger                      = logger;
     _requestUdpData              = requestUdpData;
     _sentReqP2pSeq16             = sentReqP2pSeq16;
     _ack1Scanner                 = ack1Scanner;
     _destinationNeighborNullable = destinationNeighborNullable;
     _engine                      = engine;
 }
        public Func <byte[], bool> OptionalFilter;             // verifies NPACK.NeighborHMAC, ignores invalid HMACs // returns false to ignore the processed response packet

        public bool Scan(DrpPeerEngine engine, byte[] udpData) // may throw parser exception
        {
            if (!MiscProcedures.EqualByteArrayHeader(ResponseFirstBytes, udpData, IgnoredByteAtOffset1))
            {
                if (engine.WriteToLog_udp_deepDetail_enabled)
                {
                    engine.WriteToLog_udp_deepDetail($"packet does not match to ResponseFirstBytes={MiscProcedures.ByteArrayToString(ResponseFirstBytes)} ({(PacketTypes)ResponseFirstBytes[0]}) udpData={MiscProcedures.ByteArrayToString(udpData)} ({(PacketTypes)udpData[0]})"
                                                     );
                }
                return(false);
            }
            if (OptionalFilter != null)
            {
                if (!OptionalFilter(udpData))
                {
                    //if (engine.WriteToLog_udp_deepDetail_enabled)
                    engine.WriteToLog_udp_lightPain($"packet did not pass OptionalFilter");
                    return(false);
                }
            }
            return(true);
        }
示例#5
0
        public RoutedRequest(Logger logger, ConnectionToNeighbor receivedFromNeighborNullable, IPEndPoint receivedFromEndpoint,
                             Stopwatch reqReceivedSwNullable, InviteRequestPacket inviteReqNullable,
                             RegisterRequestPacket registerReqNullable, RoutedRequest previousTrialRoutedRequestNullable = null)
        {
            InviteReq   = inviteReqNullable;
            RegisterReq = registerReqNullable;
            if (InviteReq == null && RegisterReq == null)
            {
                throw new ArgumentException();
            }
            if (InviteReq != null && RegisterReq != null)
            {
                throw new ArgumentException();
            }

            ReceivedFromNeighborNullable = receivedFromNeighborNullable;
            ReceivedFromEndpoint         = receivedFromEndpoint;
            Logger  = logger;
            _engine = logger.Engine;
            ReqReceivedSwNullable = reqReceivedSwNullable;

            if (InviteReq != null)
            {
                ReqP2pSeq16 = InviteReq.ReqP2pSeq16;
            }
            else
            {
                ReqP2pSeq16 = RegisterReq.ReqP2pSeq16;
            }

            if (previousTrialRoutedRequestNullable != null)
            {
                _repliedWithNPA = previousTrialRoutedRequestNullable._repliedWithNPA;
                TriedNeighbors  = previousTrialRoutedRequestNullable.TriedNeighbors;
            }
        }