From 5fac7d0fa1110e89971fb47e1dbc37ed6d6986b7 Mon Sep 17 00:00:00 2001 From: ruri Date: Thu, 4 Apr 2019 11:55:14 +0200 Subject: [PATCH] The dropdown box for choosing the proxy type now works with pasted proxy too --- OpenBullet/Pages/Main/ProxyManager.xaml.cs | 2 +- RuriLib/Models/CProxy.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenBullet/Pages/Main/ProxyManager.xaml.cs b/OpenBullet/Pages/Main/ProxyManager.xaml.cs index 7214eab..8428652 100644 --- a/OpenBullet/Pages/Main/ProxyManager.xaml.cs +++ b/OpenBullet/Pages/Main/ProxyManager.xaml.cs @@ -210,7 +210,7 @@ namespace OpenBullet try { CProxy proxy = new CProxy(); - proxy.Parse(p); + proxy.Parse(p, type); if (!proxy.IsNumeric || proxy.IsValidNumeric) { vm.ProxyList.Add(proxy); diff --git a/RuriLib/Models/CProxy.cs b/RuriLib/Models/CProxy.cs index 7385a67..24eb61e 100644 --- a/RuriLib/Models/CProxy.cs +++ b/RuriLib/Models/CProxy.cs @@ -119,8 +119,9 @@ namespace RuriLib.Models /// Parses a CProxy object from an advanced string. Supports Proxy Chains. /// /// The string to parse the proxy from + /// The default type to use when not specified /// The parsed CProxy object - public CProxy Parse(string proxy) + public CProxy Parse(string proxy, ProxyType defaultType = ProxyType.Http) { // Take the first proxy of the chain var chain = proxy.Split(new string[] { "->" }, 2, StringSplitOptions.None); @@ -134,6 +135,10 @@ namespace RuriLib.Models Type = type; current = current.Replace($"({groups[1].Value})", ""); } + else // Otherwise set the default type passed + { + Type = defaultType; + } // Split the host:port:user:pass portion and set the first two var fields = current.Split(':'); @@ -149,7 +154,7 @@ namespace RuriLib.Models // If the chain is not finished, set the next proxy by parsing recursively if (chain.Count() > 1) { - Next = (new CProxy()).Parse(chain[1]); + Next = (new CProxy()).Parse(chain[1], defaultType); } // Finally return this proxy