예제 #1
0
        private void importProxiesBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title       = "Proxies";
            ofd.Filter      = "Text Files|*.txt";
            ofd.Multiselect = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                ProxyMgr.Clear();
                uint badProxies       = 0;
                uint duplicateProxies = 0;
                uint dangerousProxies = 0;
                foreach (string file in ofd.FileNames)
                {
                    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        using (StreamReader sr = new StreamReader(fs, Encoding.Default))
                        {
                            string proxy;
                            while ((proxy = sr.ReadLine()) != null)
                            {
                                MyProxy myProxy = new MyProxy(proxy, true);
                                if (myProxy.isMalformed)
                                {
                                    badProxies++;
                                }
                                else
                                {
                                    if (removeDangCheck.Checked)
                                    {
                                        if (filter.isDangerous(myProxy.ToString()))
                                        {
                                            dangerousProxies++;
                                            continue;
                                        }
                                    }
                                    if (!ProxyMgr.Add(myProxy.ToString())) //adding to hashset
                                    {
                                        duplicateProxies++;
                                    }
                                }
                            }
                        }
                }

                //Update UI
                EnableScanUI();

                MessageBox.Show(string.Format("A total of {0} Proxies have been imported for scanning.{1}{2}", ProxyMgr.Count.ToString(),
                                              (badProxies + duplicateProxies) > 0 ? string.Format("{0} - {1} bad proxies and {2} duplicates were removed!",
                                                                                                  Environment.NewLine, badProxies.ToString(), duplicateProxies.ToString()):"", dangerousProxies > 0? string.Concat(Environment.NewLine,
                                                                                                                                                                                                                   " - ", dangerousProxies.ToString(), " DANGEROUS Proxies were also removed!"):""),
                                "Import Proxies", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        private void ImportProxiesBtn_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Title       = "Proxies";
            ofd.Filter      = "Text Files|*.txt";
            ofd.Multiselect = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                ProxyMgr.Clear();
                uint badProxies       = 0;
                uint duplicateProxies = 0;
                uint dangerousProxies = 0;
                foreach (var file in ofd.FileNames)
                {
                    using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        using (var sr = new StreamReader(fs, Encoding.Default)) {
                            string proxy;
                            while ((proxy = sr.ReadLine()) != null)
                            {
                                var myProxy = new MyProxy(proxy, true);
                                if (myProxy.IsMalformed)
                                {
                                    badProxies++;
                                }
                                else
                                {
                                    if (removeDangCheck.Checked)
                                    {
                                        if (filter.IsDangerous(myProxy.ToString()))
                                        {
                                            dangerousProxies++;
                                            continue;
                                        }
                                    }
                                    if (!ProxyMgr.Add(myProxy.ToString())) //adding to hashset
                                    {
                                        duplicateProxies++;
                                    }
                                }
                            }
                        }
                }

                //Update UI
                EnableScanUI();

                MessageBox.Show(string.Concat($"A total of {ProxyMgr.Count} Proxies have been imported for scanning.",
                                              (badProxies + duplicateProxies) > 0 ? $"\n - {badProxies} bad proxies and {duplicateProxies} duplicates were removed!" : string.Empty,
                                              dangerousProxies > 0 ? $"\n - {dangerousProxies} DANGEROUS Proxies were also removed!" : string.Empty),
                                "Import Proxies", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 static int Add(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         ProxyManager obj  = (ProxyManager)ToLua.CheckObject(L, 1, typeof(ProxyManager));
         IProxy       arg0 = (IProxy)ToLua.CheckObject(L, 2, typeof(IProxy));
         obj.Add(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
                endpoints.MapGet("/getSaveSDPCount", async context =>
                {
                    Manager.TryFindFirstSDP(out string sdp);
                    await context.Response.WriteAsync($"ClientProxy.getSaveSDPCount: {ClientProxy.getSaveSDPCount},");

                    //                await context.Response.WriteAsync($"Manager Count: {Manager.Count()}, First SDP: {sdp}, " +
                    //$"ClientProxy.getSaveSDPCount: {ClientProxy.getSaveSDPCount}, " +
                    //$"NetUnit.getPacketHistory: {JsonConvert.SerializeObject(NetUnit.getPacketHistory)}, " +
                    //$"NetUnit.QueueUpdateCount: {NetUnit.QueueUpdateCount}, " +
                    //$"NetUnit.CallIncomeCount: {NetUnit.CallIncomeCount}" +
                    //$"ClientProxy.ReceiveCount: {ClientProxy.ReceiveCount}" +
                    //$"ClientProxy.ReceiveDefaultCount: {ClientProxy.ReceiveDefaultCount}" +
                    //$"ClientProxy.ReceiveErrorCount: {ClientProxy.ReceiveErrorCount}" +
                    //$"ClientProxy.ErrorsValue: {JsonConvert.SerializeObject(ClientProxy.ErrorsValues[0])}" +
                    //$"NetUnit.getPacketHistoryType: {JsonConvert.SerializeObject(NetUnit.getPacketHistoryType)}");
                });
                endpoints.MapGet("/log", async context =>
                {
                    Manager.TryFindFirstSDP(out string sdp);
                    await context.Response.WriteAsync($"Manager Count: {Manager.Count()}, First SDP: {sdp}, " +
                                                      $"NetUnit.getPacketHistory: {JsonConvert.SerializeObject(NetUnit.getPacketHistory)}, ");
                });
            });

            app.Map("/ws", (con) =>
            {
                con.UseWebSockets();
                con.Use(async(HttpContext context, Func <Task> n) =>
                {
                    try
                    {
                        //執行接收
                        var socket = await context.WebSockets.AcceptWebSocketAsync();
                        var client = new ClientProxy(socket, Manager);
                        Manager.Add(client);
                        //websocket receiveAsync 如果在其他 Task 呼叫會斷線
                        await client.Net.ListenAsync();
                        Console.WriteLine("create connection");
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                });
            });
        }