Пример #1
0
        TcpForwarder(IPEndPoint proxySocket, byte socketType, bool thisIsSocks, string user, string password, delDataFilter onSend, delDataFilter onReceive)
        {
            _User      = user;
            _Password  = password;
            _OnSend    = onSend;
            _OnReceive = onReceive;

            if ((socketType == 4 || socketType == 5) && proxySocket != null)
            {
                ProxySocket = proxySocket;
                bSocketType = socketType;

                if (thisIsSocks)
                {
                    MainSocket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                    {
                        ProxyEndPoint = proxySocket,
                        ProxyType     = socketType == 4 ? ProxyTypes.Socks4 : ProxyTypes.Socks5,
                        ProxyUser     = string.IsNullOrEmpty(user) ? null : user,
                        ProxyPass     = string.IsNullOrEmpty(password) ? null : password
                    };
                    return;
                }
            }

            MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        }
Пример #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="proxySocket">ProxySocket</param>
 /// <param name="socketType">Socket Type</param>
 /// <param name="user">User</param>
 /// <param name="password">Password</param>
 public TcpForwarder(IPEndPoint proxySocket, byte socketType, string user, string password, delDataFilter onSend, delDataFilter onReceive) :
     this(proxySocket, socketType, false, user, password, onSend, onReceive)
 {
 }