Esempio n. 1
0
        // We are client
        public SSUSession(SSUHost owner, IPEndPoint remoteep, I2PRouterAddress remoteaddr, I2PKeysAndCert rri, IMTUProvider mtup, RouterContext rc)
        {
            Host              = owner;
            RemoteEP          = remoteep;
            RemoteAddr        = remoteaddr;
            RemoteRouter      = rri;
            MTUProvider       = mtup;
            MyRouterContext   = rc;
            TransportInstance = Interlocked.Increment(ref NTCPClient.TransportInstanceCounter);

#if LOG_ALL_TRANSPORT
            DebugUtils.LogDebug("SSUSession: " + DebugId + " Client instance created.");
#endif

            Fragmenter = new DataFragmenter();

            if (RemoteAddr == null)
            {
                throw new NullReferenceException("SSUSession needs an address");
            }

            IntroKey = new BufLen(FreenetBase64.Decode(RemoteAddr.Options["key"]));

            MTU = MTUProvider.GetMTU(remoteep);
        }
Esempio n. 2
0
        // Session to introducer
        internal SSUSession(SSUHost owner, IPEndPoint remoteep, IntroducerInfo ii, IMTUProvider mtup, RouterContext rc)
        {
            Host            = owner;
            RemoteEP        = remoteep;
            MTUProvider     = mtup;
            MyRouterContext = rc;

            RemoteAddr = new I2PRouterAddress(ii.Host, ii.Port, 0, "SSU");

            // TODO: This is what PurpleI2P does. Seems strange... But there is no RouterInfo available for introducer sessions.
            RemoteRouter = MyRouterContext.MyRouterIdentity;

            TransportInstance = Interlocked.Increment(ref NTCPClient.TransportInstanceCounter);

#if LOG_ALL_TRANSPORT
            DebugUtils.LogDebug("SSUSession: " + DebugId + " Introducer instance created.");
#endif

            Fragmenter = new DataFragmenter();

            if (RemoteAddr == null)
            {
                throw new NullReferenceException("SSUSession needs an address");
            }

            IntroKey = ii.IntroKey;

            MTU = MTUProvider.GetMTU(remoteep);
        }
Esempio n. 3
0
        // We are host
        public SSUSession(SSUHost owner, IPEndPoint remoteep, IMTUProvider mtup, RouterContext rc)
        {
            Host              = owner;
            RemoteEP          = remoteep;
            MTUProvider       = mtup;
            MyRouterContext   = rc;
            TransportInstance = Interlocked.Increment(ref NTCPClient.TransportInstanceCounter) + 10000;

#if LOG_ALL_TRANSPORT
            DebugUtils.LogDebug("SSUSession: " + DebugId + " Host instance created.");
#endif

            Fragmenter = new DataFragmenter();

            MTU = MTUProvider.GetMTU(remoteep);

            SendQueue.AddLast((new DeliveryStatusMessage((ulong)I2PConstants.I2P_NETWORK_ID)).Header5);
            SendQueue.AddLast((new DatabaseStoreMessage(MyRouterContext.MyRouterInfo)).Header5);

            CurrentState = new SessionCreatedState(this);
        }