예제 #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;
 }