コード例 #1
0
ファイル: Relay.cs プロジェクト: eele94/SF2Logger
        public Relay(string remoteIP, int remotePort, string localIP, int localPort)
        {
            this.IP = String.Format(remoteIP + ":" + remotePort);

            IPEndPoint local = new IPEndPoint(IPAddress.Parse(localIP), localPort);
            IPEndPoint remote = new IPEndPoint(IPAddress.Parse(remoteIP), remotePort);

            TcpForwarderSlim forwarder = new TcpForwarderSlim(this);

            Thread myNewThread = new Thread(() => forwarder.Start(local, remote));
            myNewThread.Start();
        }
コード例 #2
0
ファイル: TcpForwarderSlim.cs プロジェクト: Maufeat/300-MITM
        public void Start(IPEndPoint local, IPEndPoint remote)
        {
            _mainSocket.Bind(local);
            _mainSocket.Listen(10);

            while (true)
            {
                var source      = _mainSocket.Accept();
                var destination = new TcpForwarderSlim();
                var state       = new State(source, destination._mainSocket);
                destination.Connect(remote, source);
                source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceiveSource, state);
            }
        }
コード例 #3
0
ファイル: TcpForwarderSlim.cs プロジェクト: eele94/SF2Logger
        public void Start(IPEndPoint local, IPEndPoint remote)
        {
            MainSocket.Bind(local);
            MainSocket.Listen(10);

            while (true)
            {
                var source = MainSocket.Accept();
                var destination = new TcpForwarderSlim(this.Relayer);
                var state = new State(source, destination.MainSocket, this.Relayer);

                destination.Connect(remote, source, this.Relayer);
                source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnSourceDataReceive, state);
            }
        }