예제 #1
0
        private Tunnel CreateExploratoryOutboundTunnel()
        {
            var config = new TunnelConfig(
                TunnelConfig.TunnelDirection.Outbound,
                TunnelConfig.TunnelPool.Exploratory,
                CreateOutgoingTunnelChain());

            var tunnel = TunnelMgr.CreateTunnel(this, config);

            if (tunnel != null)
            {
                Tunnels[tunnel] = false;
                TunnelMgr.AddTunnel((OutboundTunnel)tunnel);
            }
            return(tunnel);
        }
예제 #2
0
        private OutboundTunnel CreateOutboundTunnel(IClient client, TunnelInfo prototype)
        {
            var config = new TunnelConfig(
                TunnelConfig.TunnelDirection.Outbound,
                TunnelConfig.TunnelPool.Client,
                prototype ?? CreateOutgoingTunnelChain(client));

            var tunnel = (OutboundTunnel)TunnelMgr.CreateTunnel(this, config);

            if (tunnel != null)
            {
                TunnelMgr.AddTunnel(tunnel);
                client.AddOutboundPending(tunnel);
                PendingTunnels[tunnel] = client;
            }
            return(tunnel);
        }
예제 #3
0
        private void HandleGatewayTunnelRequest(
            II2NPHeader msg,
            TunnelBuildRequestDecrypt decrypt)
        {
            var config = new TunnelConfig(
                TunnelConfig.TunnelDirection.Inbound,
                TunnelConfig.TunnelPool.External,
                new TunnelInfo(new List <HopInfo>
            {
                new HopInfo(
                    RouterContext.Inst.MyRouterIdentity,
                    new I2PTunnelId())
            }
                               ));

            var tunnel = new GatewayTunnel(this, config, decrypt.Decrypted);

            tunnel.EstablishedTime.SetNow();

            var doaccept = AcceptingTunnels(decrypt.Decrypted);

            var response = doaccept
                    ? BuildResponseRecord.RequestResponse.Accept
                    : BuildResponseRecord.DefaultErrorReply;

            Logging.LogDebug($"HandleEndpointTunnelRequest {tunnel.TunnelDebugTrace}: " +
                             $"{tunnel.Destination.Id32Short} Gateway tunnel request: {response} " +
                             $"for tunnel id {tunnel.ReceiveTunnelId}.");

            var replymsg = CreateReplyMessage(msg, decrypt, response);

            if (response == BuildResponseRecord.RequestResponse.Accept)
            {
                RunningGatewayTunnels[tunnel] = 1;
                TunnelMgr.AddTunnel(tunnel);
                AcceptedTunnelBuildRequest(decrypt.Decrypted);
            }

            TransportProvider.Send(tunnel.Destination, replymsg);
        }