public void Start(IPEndPoint lEndPoint, IPEndPoint rEndPoint)
        {
            sock.Bind(lEndPoint);
            sock.Listen(10);

            while (true)
            {
                Socket             src   = sock.Accept();
                SimpleTcpForwarder dst   = new SimpleTcpForwarder();
                ForwardStruct      state = new ForwardStruct(src, dst.sock);
                dst.Connect(rEndPoint, src);
                src.BeginReceive(state.Buf, 0, state.Buf.Length, 0, OnDataReceive, state);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ArgParse argparse = new ArgParse
                                (
                new ArgItem("src-port", "sp", true, "Source Port", "7701", ArgParse.ArgParseType.Int),
                new ArgItem("src-ip", "si", false, "Source Ip", "0.0.0.0", ArgParse.ArgParseType.String),
                new ArgItem("dst-port", "dp", true, "Destination Port", "", ArgParse.ArgParseType.Int),
                new ArgItem("dst-ip", "di", true, "Destination Ip", "", ArgParse.ArgParseType.String)
                                );

            argparse.parse(args);

            int       srcPort = argparse.Get <int>("src-port");
            IPAddress srcIp   = IPAddress.Parse(argparse.Get <string>("src-ip"));

            int       dstPort = argparse.Get <int>("dst-port");
            IPAddress dstIp   = IPAddress.Parse(argparse.Get <string>("dst-ip"));

            SimpleTcpForwarder fwder = new SimpleTcpForwarder();
            IPEndPoint         sep   = new IPEndPoint(srcIp, srcPort);
            IPEndPoint         dep   = new IPEndPoint(dstIp, dstPort);

            fwder.Start(sep, dep);
        }