public override void OnConnect(ProxyClient sender) { var source = (SslStream)sender.SourceStream; var remote = (SslStream)sender.RemoteStream; source.AuthenticateAsServer(Certificate, false, SslProtocols.Default, false); remote.AuthenticateAsClient(RemoteAddress); base.OnConnect(sender); }
public virtual void OnException(ProxyClient sender, Exception ex) { lock (Clients) { int idx = Clients.IndexOf(sender); if (idx != -1) { Clients.RemoveAt(idx); } } sender.Dispose(); StaticLogger.Debug(ex); }
protected virtual void OnAccept(IAsyncResult ar) { ProxyClient client = null; try { if (!IsListening) { return; } client = NewClient(Listener.EndAcceptTcpClient(ar)); Listener.BeginAcceptTcpClient(OnAccept, null); lock (Clients) Clients.Add(client); client.Start(RemoteAddress, RemotePort); if (client.SourceTcp.Client != null) { StaticLogger.Info(string.Format("Client {0} connected", client.SourceTcp.Client.RemoteEndPoint)); } } catch (Exception ex) { if (client != null) { OnException(client, ex); } else { //Ignore objectdisposed, happens when stopping if (!(ex is ObjectDisposedException)) { StaticLogger.Error(ex); } } } }
public override void OnException(ProxyClient sender, Exception ex) { IsConnected = false; base.OnException(sender, ex); }
public override void OnConnect(ProxyClient sender) { IsConnected = true; base.OnConnect(sender); }
public virtual void OnConnect(ProxyClient sender) { }
public virtual void OnReceive(ProxyClient sender, byte[] buffer, int idx, int len) { }
public virtual void OnException(ProxyClient sender, Exception ex) { lock (Clients) { int idx = Clients.IndexOf(sender); if (idx != -1) Clients.RemoveAt(idx); } sender.Dispose(); StaticLogger.Debug(ex); }