示例#1
0
        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);
        }
示例#2
0
		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);

		}
示例#3
0
 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);
 }
示例#4
0
        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);
                    }
                }
            }
        }
示例#5
0
		public override void OnException(ProxyClient sender, Exception ex)
		{
			IsConnected = false;
			base.OnException(sender, ex);
		}
示例#6
0
		public override void OnConnect(ProxyClient sender)
		{
			IsConnected = true;
			base.OnConnect(sender);
		}
示例#7
0
 public virtual void OnConnect(ProxyClient sender)
 {
 }
示例#8
0
 public virtual void OnReceive(ProxyClient sender, byte[] buffer, int idx, int len)
 {
 }
示例#9
0
文件: ProxyHost.cs 项目: wzpyh/Client
		public virtual void OnConnect(ProxyClient sender)
		{
			
		}
示例#10
0
文件: ProxyHost.cs 项目: wzpyh/Client
		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);
		}
示例#11
0
文件: ProxyHost.cs 项目: wzpyh/Client
		public virtual void OnReceive(ProxyClient sender, byte[] buffer, int idx, int len)
		{
		}
示例#12
0
 public override void OnException(ProxyClient sender, Exception ex)
 {
     IsConnected = false;
     base.OnException(sender, ex);
 }
示例#13
0
 public override void OnConnect(ProxyClient sender)
 {
     IsConnected = true;
     base.OnConnect(sender);
 }