Exemplo 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);
        }
Exemplo n.º 2
0
        // TODO: Remove
        internal ClientDestination(ClientTunnelProvider tp, bool publishdest, ClientDestination remotedest)
        {
            ClientTunnelMgr    = tp;
            PublishDestination = publishdest;
            NewIdentity();

            TestRemoteDest = remotedest;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start the router with the current RouterContext settings.
        /// </summary>
        public static void Start()
        {
            lock ( StartedLock )
            {
                if (Started)
                {
                    return;
                }

                try
                {
                    var rci = RouterContext.Inst;
                    NetDb.Start();

                    Logging.Log("I: " + RouterContext.Inst.MyRouterInfo.ToString());
                    Logging.Log("Published: " + RouterContext.Inst.Published.ToString());

                    Logging.Log("Connecting...");
                    TransportProvider.Start();
                    TunnelProvider.Start();

                    ClientMgr        = new ClientTunnelProvider(TunnelProvider.Inst);
                    ExplorationMgr   = new ExplorationTunnelProvider(TunnelProvider.Inst);
                    TransitTunnelMgr = new TransitTunnelProvider(TunnelProvider.Inst);

                    Worker = new Thread(Run)
                    {
                        Name         = "Router",
                        IsBackground = true
                    };
                    Worker.Start();

                    NetDb.Inst.IdentHashLookup.LeaseSetReceived += IdentHashLookup_LeaseSetReceived;
                    NetDb.Inst.IdentHashLookup.LookupFailure    += IdentHashLookup_LookupFailure;

                    Started = true;
                }
                catch (Exception ex)
                {
                    Logging.Log(ex);
                }
            }
        }