Example #1
0
        void socksServer_onUpdateConnection(ReverseProxyClient proxyClient)
        {
            if (proxyClient.ListItem != null)
            {
                this.Invoke(new Invoky(() =>
                {
                    lock (LvConnections)
                    {
                        string totalReceivedStr = GetSizeStr(proxyClient.LengthReceived);
                        string totalSendStr     = GetSizeStr(proxyClient.LengthSended);

                        proxyClient.ListItem.SubItems[0].Text = proxyClient.TargetServer;
                        proxyClient.ListItem.SubItems[1].Text = proxyClient.TargetPort.ToString();

                        if (proxyClient.ListItem.SubItems[2].Text != totalReceivedStr)
                        {
                            proxyClient.ListItem.SubItems[2].Text = totalReceivedStr;
                        }

                        if (proxyClient.ListItem.SubItems[3].Text != totalSendStr)
                        {
                            proxyClient.ListItem.SubItems[3].Text = totalSendStr;
                        }



                        if (!proxyClient.IsConnected)
                        {
                            LvConnections.Items.Remove(proxyClient.ListItem);
                        }
                    }
                }));
            }
        }
Example #2
0
        private void killConnectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lock (_reverseProxyHandler)
            {
                if (lstConnections.SelectedIndices.Count > 0)
                {
                    //copy the list, it could happen that suddenly the items de-select
                    int[] items = new int[lstConnections.SelectedIndices.Count];
                    lstConnections.SelectedIndices.CopyTo(items, 0);

                    foreach (int index in items)
                    {
                        if (index < _openConnections.Length)
                        {
                            ReverseProxyClient connection = _openConnections[index];
                            connection?.Disconnect();
                        }
                    }
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            ReverseProxyClient client = new ReverseProxyClient();

            Resource res1 = new Resource();

            res1.Uri   = "res1";
            res1.Value = 100;
            Resource res2 = new Resource();

            res2.Uri   = "res2";
            res2.Value = 200;

            client.create(res1);    // 201
            client.create(res2);    // 201
            client.create(res2);    // 403

            client.get("res3");     // null
            client.get("res1");     // res1 from ApplicationServer
            client.get("res1");     // res1 from CachingProxy

            client.Close();
        }
Example #4
0
        private void killConnectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lock (SocksServer)
            {
                if (lstConnections.SelectedIndices.Count > 0)
                {
                    int[] items = new int[lstConnections.SelectedIndices.Count];
                    lstConnections.SelectedIndices.CopyTo(items, 0);

                    foreach (int index in items)
                    {
                        if (index < _openConnections.Length)
                        {
                            ReverseProxyClient connection = _openConnections[index];
                            if (connection != null)
                            {
                                connection.Disconnect();
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        private void killConnectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lock (SocksServer)
            {
                if (LvConnections.SelectedIndices.Count > 0)
                {
                    //copy the list, it could happen the suddenly the items de-select
                    int[] items = new int[LvConnections.SelectedIndices.Count];
                    LvConnections.SelectedIndices.CopyTo(items, 0);

                    foreach (int index in items)
                    {
                        if (index < _openConnections.Length)
                        {
                            ReverseProxyClient connection = _openConnections[index];
                            if (connection != null)
                            {
                                connection.Disconnect();
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        private void LvConnections_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            lock (SocksServer)
            {
                if (e.ItemIndex < _openConnections.Length)
                {
                    ReverseProxyClient connection = _openConnections[e.ItemIndex];

                    e.Item = new ListViewItem(new string[]
                    {
                        connection.Client.EndPoint.ToString(),
                        connection.Client.Value.Country,
                        connection.TargetServer + (connection.HostName.Length > 0 ? "    (" + connection.HostName + ")" : ""),
                        connection.TargetPort.ToString(),
                        Helper.GetDataSize(connection.LengthReceived),
                        Helper.GetDataSize(connection.LengthSended),
                        connection.Type.ToString()
                    })
                    {
                        Tag = connection
                    };
                }
            }
        }
Example #7
0
        private void LvConnections_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            lock (SocksServer)
            {
                if (e.ItemIndex < _openConnections.Length)
                {
                    ReverseProxyClient connection = _openConnections[e.ItemIndex];

                    e.Item = new ListViewItem(new string[]
                    {
                        connection.Client.EndPoint.ToString(),
                        connection.Client.Value.Ülke,
                        (connection.HostName.Length > 0 && connection.HostName != connection.TargetServer) ? string.Format("{0}  ({1})", connection.HostName, connection.TargetServer) : connection.TargetServer,
                        connection.TargetPort.ToString(),
                        DosyaYardımcısı.GetDataSize(connection.LengthReceived),
                        DosyaYardımcısı.GetDataSize(connection.LengthSent),
                        connection.Type.ToString()
                    })
                    {
                        Tag = connection
                    };
                }
            }
        }
Example #8
0
        private void LvConnections_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            lock (_reverseProxyHandler)
            {
                if (e.ItemIndex < _openConnections.Length)
                {
                    ReverseProxyClient connection = _openConnections[e.ItemIndex];

                    e.Item = new ListViewItem(new string[]
                    {
                        connection.Client.EndPoint.ToString(),
                        connection.Client.Value.Country,
                        (connection.HostName.Length > 0 && connection.HostName != connection.TargetServer) ? string.Format("{0}  ({1})", connection.HostName, connection.TargetServer) : connection.TargetServer,
                        connection.TargetPort.ToString(),
                        StringHelper.GetHumanReadableFileSize(connection.LengthReceived),
                        StringHelper.GetHumanReadableFileSize(connection.LengthSent),
                        connection.Type.ToString()
                    })
                    {
                        Tag = connection
                    };
                }
            }
        }
Example #9
0
 void socksServer_onConnectionEstablished(ReverseProxyClient proxyClient)
 {
     if (proxyClient.ListItem == null)
     {
         this.Invoke(new Invoky(() =>
         {
             lock (LvConnections)
             {
                 proxyClient.ListItem = new ListViewItem(new string[]
                 {
                     proxyClient.TargetServer,
                     proxyClient.TargetPort.ToString(),
                     proxyClient.LengthReceived / 1024 + "KB",
                     proxyClient.LengthSended / 1024 + "KB",
                     proxyClient.Type.ToString()
                 })
                 {
                     Tag = proxyClient
                 };
                 LvConnections.Items.Add(proxyClient.ListItem);
             }
         }));
     }
 }
Example #10
0
 void socksServer_onUpdateConnection(ReverseProxyClient proxyClient)
 {
 }
Example #11
0
        private void Execute(ISender client, ReverseProxyDisconnect message)
        {
            ReverseProxyClient socksClient = _socksServer.GetClientByConnectionId(message.ConnectionId);

            socksClient?.Disconnect();
        }
Example #12
0
        private void Execute(ISender client, ReverseProxyData message)
        {
            ReverseProxyClient socksClient = _socksServer.GetClientByConnectionId(message.ConnectionId);

            socksClient?.SendToClient(message.Data);
        }
Example #13
0
        private void Execute(ISender client, ReverseProxyConnectResponse message)
        {
            ReverseProxyClient socksClient = _socksServer.GetClientByConnectionId(message.ConnectionId);

            socksClient?.HandleCommandResponse(message);
        }
Example #14
0
 void socksServer_onUpdateConnection(ReverseProxyClient proxyClient)
 {
     OnReport(_socksServer.OpenConnections);
 }
Example #15
0
        private void Execute(ISender client, ReverseProxyData message)
        {
            ReverseProxyClient proxyClient = _client.GetReverseProxyByConnectionId(message.ConnectionId);

            proxyClient?.SendToTargetServer(message.Data);
        }
Example #16
0
 void socksServer_onConnectionEstablished(ReverseProxyClient proxyClient)
 {
 }
 private void ReverseProxyCommandOnClientAdded(object sender, ReverseProxyClient reverseProxyClient)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => ReverseProxyClients.Add(reverseProxyClient)));
 }
Example #18
0
 void socksServer_onConnectionEstablished(ReverseProxyClient proxyClient)
 {
     OnReport(_socksServer.OpenConnections);
 }