///<summary>Called when there's an incoming client connection waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> public override void OnAccept(IAsyncResult ar) { try { Socket NewSocket = ListenSocket.EndAccept(ar); try { //Restart Listening ListenSocket.BeginAccept(new AsyncCallback(OnAccept), ListenSocket); } catch { Dispose(); } if (NewSocket != null) { HttpClient NewClient = new HttpClient(NewSocket, RemoveClient); AddClient(NewClient); NewClient.StartHandshake(); if (OnClientAdded != null) { OnClientAdded.Invoke(NewClient); } } } catch { } }
///<summary>Called when there's an incoming client connection waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> public override void OnAccept(IAsyncResult ar) { try { Socket NewSocket = ListenSocket.EndAccept(ar); //Console.WriteLine("Connection from " + NewSocket.RemoteEndPoint); if (NewSocket != null) { if (WhitelistIPs != null && WhitelistIPs.Count > 0 && !WhitelistIPs.Contains((NewSocket.RemoteEndPoint as IPEndPoint).Address.ToString())) { //TODO: Log this Console.WriteLine("Invalid connection from " + NewSocket.RemoteEndPoint); try { NewSocket.Close(); } catch { } } else { SocksClient NewClient = new SocksClient(NewSocket, new DestroyDelegate(this.RemoveClient), AuthList); AddClient(NewClient); NewClient.StartHandshake(); } } } catch {} try { //Restart Listening ListenSocket.BeginAccept(new AsyncCallback(this.OnAccept), ListenSocket); } catch { Dispose(); } }
public override void OnAccept(IAsyncResult ar) { try { Socket newSocket = ListenSocket.EndAccept(ar); if (newSocket != null) { HttpClient NewClient = new HttpClient(newSocket, new DestroyDelegate(this.RemoveClient), Validator); AddClient(NewClient); NewClient.StartHandshake(); } } catch (Exception ex) { Log.Write(MethodInfo.GetCurrentMethod(), ex); } try { ListenSocket.BeginAccept(new AsyncCallback(this.OnAccept), ListenSocket); } catch (Exception ex) { Log.Write(MethodInfo.GetCurrentMethod(), ex); Dispose(); } }
///<summary>Called when there's an incoming client connection waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> public override void OnAccept(IAsyncResult ar) { try { Socket NewSocket = ListenSocket.EndAccept(ar); if (NewSocket != null) { PortMapClient NewClient = new PortMapClient(NewSocket, RemoveClient, MapTo); AddClient(NewClient); NewClient.StartHandshake(); } } catch { } try { //Restart Listening ListenSocket.BeginAccept(new AsyncCallback(OnAccept), ListenSocket); } catch { Dispose(); } }
public override void OnAccept(IAsyncResult ar) { try { Socket inputSocket = ListenSocket.EndAccept(ar); if (inputSocket != null) { inputSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); Socket outputSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); outputSocket.Connect(MapTo); outputSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); //inputSocket.ReceiveTimeout = 180000; //inputSocket.SendTimeout = 180000; //outputSocket.ReceiveTimeout = 180000; //outputSocket.SendTimeout = 180000; forwarderTx = GetInputToOutputForwarder(inputSocket, outputSocket); forwarderRx = GetOutputToInputForwarder(outputSocket, inputSocket); AddClient(forwarderTx); AddClient(forwarderRx); forwarderTx.StartForward(); forwarderRx.StartForward(); } } catch { } try { //Restart Listening ListenSocket.BeginAccept(new AsyncCallback(this.OnAccept), ListenSocket); } catch { Dispose(); } }
///<summary>Called when there's an incoming client connection waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> public override void OnAccept(IAsyncResult ar) { try { Socket NewSocket = ListenSocket.EndAccept(ar); if (NewSocket != null) { HttpClient NewClient = new HttpClient(NewSocket, new DestroyDelegate(this.RemoveClient)); NewClient.StartHandshake(); } } catch { } try { //Restart Listening ListenSocket.BeginAccept(new AsyncCallback(this.OnAccept), ListenSocket); } catch { Dispose(); } }
public override void OnAccept(IAsyncResult ar) { try { Socket clientSocket = ListenSocket.EndAccept(ar); if (clientSocket != null) { var client = new HttpClient(clientSocket, RemoveClient, UpdataUrlLog); AddClient(client); client.StartHandshake(); } } catch (Exception ex) { this.ExceptionHandler?.Invoke(ex); } try { ListenSocket.BeginAccept(OnAccept, ListenSocket); } catch (Exception ex) { this.ExceptionHandler?.Invoke(ex); Dispose(); } }
///<summary>Called when there's a connection from the local FTP client waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> private void OnPasvAccept(IAsyncResult ar) { try { ClientSocket = ListenSocket.EndAccept(ar); StartHandshake(); } catch { Dispose(); } }
///<summary>Called when there's a connection from the remote FTP server waiting to be accepted.</summary> ///<param name="ar">The result of the asynchronous operation.</param> private void OnPortAccept(IAsyncResult ar) { try { DestinationSocket = ListenSocket.EndAccept(ar); ListenSocket.Close(); ListenSocket = null; StartHandshake(); } catch { Dispose(); } }
private void EndAccept(IAsyncResult ar) { var listener = ListenSocket.EndAccept(ar); var connId = Guid.NewGuid().ToString(); var args = ClientPool.Take(); args.AcceptSocket = listener; args.UserToken = ServerConnectionFactory.Create(this, connId); args.LastResponse = DateTime.UtcNow.AddMinutes(1); listener.BeginReceive(_receiveBuffer, 0, _receiveBuffer.Length, SocketFlags.None, EndReceive, args); ListenSocket.BeginAccept(EndAccept, ListenArgs); ClientsToSocket.TryAdd(connId, args); OnClientConnectedInvoke((ServerConnectionBase)args.UserToken); }
public override void OnAccept(IAsyncResult ar) { try { var newSocket = ListenSocket.EndAccept(ar); if (newSocket != null) { var newClient = new HttpClient(newSocket, RemoveClient); AddClient(newClient); newClient.StartHandshake(); } } catch { } try { //Restart Listening ListenSocket.BeginAccept(OnAccept, ListenSocket); } catch { Dispose(); } }