示例#1
0
文件: Session.cs 项目: nikes/Link
        public Session(
            IPool <DataStream> dataStreamPool = null,
            PacketReader packetReader         = null,
            PacketWriter packetWriter         = null,
            PacketPolicy packetPolicy         = null,
            ProtoListTable baseProto          = null)
        {
            if (dataStreamPool == null)
            {
                dataStreamPool = Link.Pools.DataStreamPool.Instance;
            }
            if (packetReader == null)
            {
                packetReader = new PacketReader(dataStreamPool.Take(), dataStreamPool.Take());
            }
            if (packetWriter == null)
            {
                packetWriter = new PacketWriter(dataStreamPool.Take(), dataStreamPool.Take());
            }
            if (packetPolicy == null)
            {
                packetPolicy = PacketPolicy.AllAcceptPolicy;
            }

            DataStreamPool = dataStreamPool;
            PacketReader   = packetReader;
            PacketWriter   = packetWriter;
            PacketPolicy   = packetPolicy;

            if (baseProto == null)
            {
                Proto = new ProtoListTable();
            }
            else
            {
                Proto = baseProto;
            }

            Handler       = new PacketHandlerTable();
            Handler.Proto = Proto;
            Modules       = new ModulesManager(this);

            connectionInputRoute  = new RouteChain();
            connectionOutputRoute = new RouteOutputHandler(SendNext);

            InputChain  = new RouteSession();
            OutputChain = new RouteSession();

            InputChain.Handler = OutputChain.Handler = Handler;
            InputChain.Session = OutputChain.Session = this;

            connectionInputRoute.Next = InputChain;
            OutputChain.Next          = connectionOutputRoute;

            InputChain.IsInput  = true;
            OutputChain.IsInput = false;

            InputChain.Redirect  = OutputChain;
            OutputChain.Redirect = InputChain;
        }
示例#2
0
文件: MitmPair.cs 项目: nikes/Link
        internal void Configure()
        {
            Proto = Client.Proto;

            RouteChain.Combine(Client.InputChain, Server.OutputChain);
            RouteChain.Combine(Server.InputChain, Client.OutputChain);

            Client.StateChanged += OnStateChanged;
            Server.StateChanged += OnStateChanged;
        }
示例#3
0
 public static void Combine(RouteChain inputRoute, Route outputRoute)
 {
     inputRoute.Next = outputRoute;
 }