/// <summary> /// 启动身份验证过程 /// </summary> /// <param name="Connection"></param> /// <param name="Callback"></param> internal void StartAuthentication(Socket Connection, AuthenticationCompleteDelegate Callback) { this._Connection = Connection; this._Callback = Callback; try { _Bytes = null; Connection.BeginReceive(_Buffer, 0, _Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnRecvRequest), Connection); } catch (Exception ex) { Log.AddLog("AuthBase处理身份验证过程时出错|" + ex.Message); Callback(false); } }
internal void StartHandshake() { try { _ClientSocket.BeginReceive(_Buffer, 0, 1, SocketFlags.None, new AsyncCallback(this.OnStartSocksProtocol), _ClientSocket); } catch (Exception ex) { Log.AddLog(ex.Message); Dispose(); } }
/// <summary> /// 初始化服务器 /// </summary> /// <param name="ipAddress">监听IP地址</param> /// <param name="port">监听的端口</param> /// <param name="maxUser">最大用户数</param> internal Socks5Listener(String ipAddress, Int32 port, Int32 maxUser, ref LogMain log) { try { if (Log == null) { Log = log; } if (_AuthList == null) { _AuthList = new AuthenticationList(); } this._Address = IPAddress.Parse(ipAddress); this._Port = port; this._MaxUser = maxUser; } catch (Exception ex) { Log.AddLog("在初始化监听对象时出错|" + ex.Message); } }
/// <summary> /// 开始从客户端接收字节 /// </summary> internal void StartNegotiating() { try { _Connection.BeginReceive(_Buffer, 0, _Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnReceiveBytes), _Connection); } catch (Exception ex) { Log.AddLog("Socks5Handler在处理接收字节时出错|" + ex.Message); Dispose(false); } }