Exemplo n.º 1
0
        void StartNewUpdatesRouterInfo()
        {
            var list = GetNewFFList(
                RouterContext.Inst.MyRouterIdentity.IdentHash,
                4);

            foreach (var ff in list)
            {
                try
                {
                    var token = BufUtils.RandomUint() | 1;

                    Logging.Log(string.Format("FloodfillUpdater: {0}, RI, token: {1,10}, dist: {2}.",
                                              ff.Id32Short, token,
                                              ff ^ RouterContext.Inst.MyRouterIdentity.IdentHash.RoutingKey));

                    OutstandingRequests[token] = new FFUpdateRequestInfo(
                        ff,
                        token,
                        RouterContext.Inst.MyRouterIdentity.IdentHash);

                    SendUpdate(ff, token);
                }
                catch (Exception ex)
                {
                    Logging.Log(ex);
                }
            }
        }
Exemplo n.º 2
0
        private void SendUpdate(I2PIdentHash ff, uint token)
        {
            // If greater than zero, a DeliveryStatusMessage
            // is requested with the Message ID set to the value of the Reply Token.
            // A floodfill router is also expected to flood the data to the closest floodfill peers
            // if the token is greater than zero.
            // https://geti2p.net/spec/i2np#databasestore

            var ds = new DatabaseStoreMessage(RouterContext.Inst.MyRouterInfo,
                                              token, RouterContext.Inst.MyRouterInfo.Identity.IdentHash, 0);

            lock ( OutstandingRequests )
            {
                OutstandingRequests[token] = new FFUpdateRequestInfo(ff);
            }

            TransportProvider.Send(ff, ds);
        }
Exemplo n.º 3
0
        void StartNewUpdatesLeaseSet(I2PLeaseSet ls)
        {
            // old lease sets are out of date
            while (OutstandingRequests.TryRemove(
                       OutstandingRequests.Where(r => r.Value?.LeaseSet == ls)
                       .Select(r => r.Key)
                       .FirstOrDefault(),
                       out var _))
            {
            }

            var list = GetNewFFList(
                ls.Destination.IdentHash,
                2);

            var destinations = list.Select(i => NetDb.Inst[i]);

            foreach (var ff in destinations)
            {
                try
                {
                    var ffident = ff.Identity.IdentHash;
                    var token   = BufUtils.RandomUint() | 1;

                    Logging.Log($"FloodfillUpdater: New LS update started for " +
                                $"{ls.Destination.IdentHash.Id32Short}, {ls.Leases.Count()} leases " +
                                $"update {ffident.Id32Short}, token {token,10}, " +
                                $"dist: {ffident ^ ls.Destination.IdentHash.RoutingKey}.");

                    OutstandingRequests[token] = new FFUpdateRequestInfo(ffident, token, ls, 0);

                    SendLeaseSetUpdateGarlic(ffident, ff.Identity.PublicKey, ls, token);
                }
                catch (Exception ex)
                {
                    Logging.Log(ex);
                }
            }
        }
Exemplo n.º 4
0
        private void TimeoutRegenerateLSUpdate(IEnumerable <FFUpdateRequestInfo> lsets)
        {
            foreach (var lsinfo in lsets)
            {
                OutstandingRequests.TryRemove(lsinfo.Token, out _);

                var token = BufUtils.RandomUint() | 1;

                var ls = lsinfo.LeaseSet;

                var getnext = DateTime.UtcNow.Hour >= 23;
                var list    = NetDb.Inst.GetClosestFloodfill(
                    ls.Destination.IdentHash,
                    2 + 2 * lsinfo.Retries,
                    null,
                    getnext);

                var ff      = list.Random();
                var ffident = NetDb.Inst[ff];

                Logging.Log($"FloodfillUpdater: LS {ls.Destination.IdentHash.Id32Short} " +
                            $"replacement update {ff.Id32Short}, token {token,10}, " +
                            $"dist: {ff ^ ls.Destination.IdentHash.RoutingKey}.");

                SendLeaseSetUpdateGarlic(
                    ffident.Identity.IdentHash,
                    ffident.Identity.PublicKey,
                    ls,
                    token);

                OutstandingRequests[token] = new FFUpdateRequestInfo(
                    ff,
                    token,
                    ls,
                    lsinfo.Retries + 1);
            }
        }
Exemplo n.º 5
0
        private void TimeoutRegenerateRIUpdate(IEnumerable <FFUpdateRequestInfo> rinfos)
        {
            var list = GetNewFFList(
                RouterContext.Inst.MyRouterIdentity.IdentHash,
                rinfos.Count());

            foreach (var rinfo in rinfos)
            {
                OutstandingRequests.TryRemove(rinfo.Token, out _);
                var ff = list.Random();

                var token = BufUtils.RandomUint() | 1;

                Logging.LogDebug(string.Format("FloodfillUpdater: RI replacement update {0}, token {1,10}, dist: {2}.",
                                               ff.Id32Short, token,
                                               ff ^ RouterContext.Inst.MyRouterIdentity.IdentHash.RoutingKey));

                SendUpdate(ff, token);
                OutstandingRequests[token] = new FFUpdateRequestInfo(
                    ff,
                    token,
                    RouterContext.Inst.MyRouterIdentity.IdentHash);
            }
        }