예제 #1
0
        private void b()
        {
            bool flag = false;

            byte[]   buffer = new byte[11680];
            DateTime d      = DateTime.Now;

            while (!this.f)
            {
                try
                {
                    int      num = this.e.Receive(buffer, 11680, SocketFlags.None);
                    DateTime now = DateTime.Now;
                    if (this.e != null && this.e.IsClose)
                    {
                        flag = true;
                        break;
                    }
                    if (this.f)
                    {
                        break;
                    }
                    this.a((double)this.n);
                    if (num > 0)
                    {
                        this.d.Send(buffer, num, SocketFlags.None);
                        if (Analyzer.instance().Add(this.h, this.i, this.e, buffer, num, true))
                        {
                            Analyzer.instance().Close(this.h, this.i, this.e);
                        }
                        if ((now - d).TotalSeconds > 5.0)
                        {
                            this.m = 0;
                            this.e.BeginReceive(this.k, 11680, SocketFlags.None, new AsyncCallback(this.b), null);
                            return;
                        }
                        d = now;
                    }
                    else
                    {
                        this.e();
                    }
                }
                catch (Exception arg_113_0)
                {
                    Logging.LogUsefulException(arg_113_0);
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                this.e();
                return;
            }
        }
예제 #2
0
 public void a(Configuration A_0, byte[] A_1, int A_2, Socket A_3, string A_4, bool A_5)
 {
     this.b = A_1;
     this.c = A_2;
     this.d = new ProxySocketTunLocal(A_3);
     this.d.local_sendback_protocol = A_4;
     this.a = A_0;
     this.g = A_5;
     this.d();
 }
예제 #3
0
 public void Start(Configuration config, byte[] firstPacket, Socket socket, string local_sendback_protocol, bool proxy)
 {
     _firstPacket = firstPacket;
     _local       = new ProxySocketTunLocal(socket)
     {
         local_sendback_protocol = local_sendback_protocol
     };
     _config      = config;
     _local_proxy = proxy;
     Connect();
 }
예제 #4
0
 public bool AddRef(ProxySocketTunLocal socket)
 {
     lock (this)
     {
         if (sockets.ContainsKey(socket))
         {
             sockets[socket] += 1;
         }
         else
         {
             sockets[socket] = 1;
         }
         return(true);
     }
 }
예제 #5
0
 public bool DecRef(ProxySocketTunLocal socket)
 {
     lock (this)
     {
         if (sockets.ContainsKey(socket))
         {
             sockets[socket] -= 1;
             if (sockets[socket] == 0)
             {
                 sockets.Remove(socket);
             }
         }
         else
         {
             return(false);
         }
         return(true);
     }
 }
예제 #6
0
 public void CloseAll()
 {
     ProxySocketTunLocal[] s;
     lock (this)
     {
         s = new ProxySocketTunLocal[sockets.Count];
         sockets.Keys.CopyTo(s, 0);
     }
     foreach (ProxySocketTunLocal socket in s)
     {
         try
         {
             //socket.Shutdown(SocketShutdown.Send);
             socket.Shutdown(SocketShutdown.Both);
             //socket.Close();
         }
         catch
         {
         }
     }
 }