The dropdown box for choosing the proxy type now works with pasted proxy too

This commit is contained in:
ruri
2019-04-04 11:55:14 +02:00
parent 043c4ad635
commit 5fac7d0fa1
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -119,8 +119,9 @@ namespace RuriLib.Models
/// Parses a CProxy object from an advanced string. Supports Proxy Chains.
/// </summary>
/// <param name="proxy">The string to parse the proxy from</param>
/// <param name="defaultType">The default type to use when not specified</param>
/// <returns>The parsed CProxy object</returns>
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