Esempio n. 1
0
        internal ClientDestination(ClientTunnelProvider tp, I2PDestinationInfo dest, bool publishdest)
        {
            ClientTunnelMgr    = tp;
            PublishDestination = publishdest;
            ThisDestination    = dest;
            MyDestination      = new I2PDestination(ThisDestination);

            LeaseSet = new I2PLeaseSet(MyDestination, null, new I2PLeaseInfo(ThisDestination));

            IncommingSessions = new ReceivedSessions(ThisDestination.PrivateKey);
            Destinations      = new DestinationSessions((ls, header, inf) =>
            {
                DebugUtils.LogDebug(string.Format("ClientDestination: Execute: Sending data. TrackingId: {0} ({1}) ack {2}, msg {3}.",
                                                  inf.TrackingId, inf.KeyType, inf.AckMessageId, header));

                var outtunnel = OutboundEstablishedPool.Random();
                if (outtunnel == null || ls == null || ls.Leases.Count == 0)
                {
                    throw new FailedToConnectException("No tunnels available");
                }
                var lease = ls.Leases.Random();

                outtunnel.Send(
                    new TunnelMessageTunnel(header, lease.TunnelGw, lease.TunnelId));
            },
                                                        () => InboundEstablishedPool.Random());

            NetDb.Inst.IdentHashLookup.LeaseSetReceived += new IdentResolver.IdentResolverResultLeaseSet(IdentHashLookup_LeaseSetReceived);
            NetDb.Inst.IdentHashLookup.LookupFailure    += new IdentResolver.IdentResolverResultFail(IdentHashLookup_LookupFailure);
        }
Esempio n. 2
0
        private void NewIdentity()
        {
            ThisDestination = new I2PDestinationInfo(I2PSigningKey.SigningKeyTypes.EdDSA_SHA512_Ed25519);
            MyDestination   = new I2PDestination(ThisDestination);

            LeaseSet = new I2PLeaseSet(MyDestination, null, new I2PLeaseInfo(ThisDestination));

            IncommingSessions = new ReceivedSessions(ThisDestination.PrivateKey);
            Destinations      = new DestinationSessions((dest, header, inf) =>
            {
                DebugUtils.LogDebug(string.Format("ClientDestination: Execute: Sending data. TrackingId: {0} ({1}) ack {2}, msg {3}.",
                                                  inf.TrackingId, inf.KeyType, inf.AckMessageId, header));

                var outtunnel = OutboundEstablishedPool.Random();
                outtunnel.Send(
                    new TunnelMessageTunnel(header, TestRemoteDest.InboundEstablishedPool.Random()));
            },
                                                        () => InboundEstablishedPool.Random());
        }