Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Slight refactoring due to boredom
Browse files Browse the repository at this point in the history
  • Loading branch information
Laiteux committed Nov 23, 2020
1 parent bbab6a6 commit 53d95b1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/Club_Cooee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static async Task Main()

var checker = new CheckerBuilder(checkerSettings, CheckAsync)
.WithCombos(File.ReadAllLines("Combos.txt"))
.WithProxies(File.ReadAllLines("Proxies.txt"), new ProxySettings(ProxyProtocol.HTTP))
.WithProxies(File.ReadAllLines("Proxies.txt"), new ProxySettings(ProxyProtocol.Http))
.Build();

var consoleManager = new ConsoleManager(checker);
Expand Down
3 changes: 1 addition & 2 deletions src/Milky/Checker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ private async Task StartCpmCounterAsync()
}
}

// It just looks better to have a separate method for this
private void OutputCombo(Combo combo, CheckResult checkResult)
{
if (checkResult.ComboResult == ComboResult.Invalid && !_outputSettings.OutputInvalids)
Expand All @@ -196,7 +195,7 @@ private void OutputCombo(Combo combo, CheckResult checkResult)
if (checkResult.Captures != null && checkResult.Captures.Count != 0)
{
IEnumerable<string> captures = checkResult.Captures
.Where(c => c.Value != null && !string.IsNullOrWhiteSpace(c.Value.ToString())) // If capture value is either null, empty or white-space, we don't want it to be included
.Where(c => !string.IsNullOrWhiteSpace(c.Value?.ToString())) // If capture value is either null, empty or white-space, we don't want it to be included
.Select(c => $"{c.Key} = {c.Value}");

outputBuilder.Append(_outputSettings.CaptureSeparator).AppendJoin(_outputSettings.CaptureSeparator, captures);
Expand Down
2 changes: 1 addition & 1 deletion src/Milky/CheckerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public CheckerBuilder WithOutputSettings(OutputSettings outputSettings)

public CheckerBuilder WithCombos(IEnumerable<Combo> combos)
{
foreach (var combo in combos.Where(c => c.IsValid))
foreach (var combo in combos.Where(c => c.Valid))
{
_combos.Add(combo);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Milky/Enums/ProxyProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
public enum ProxyProtocol
{
HTTP,
SOCKS4,
SOCKS4a,
SOCKS5
Http,
Socks4,
Socks4A,
Socks5
}
}
2 changes: 1 addition & 1 deletion src/Milky/Models/CheckerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal CheckerInfo(int combos)

public CheckerStatus Status { get; internal set; }

public int Combos { get; }
public int Combos { get; private set; }

public int Checked { get; internal set; }

Expand Down
4 changes: 2 additions & 2 deletions src/Milky/Models/Combo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public Combo(string combo, string separator = ":")
Username = split[0];
Password = split[1];

IsValid = true;
Valid = true;
}

internal bool IsValid { get; }
internal bool Valid { get; }

public string Username { get; }

Expand Down
16 changes: 8 additions & 8 deletions src/Milky/Models/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public Proxy(string proxy, ProxySettings settings)

internal bool Valid { get; }

public string Host { get; }
internal ProxySettings Settings { get; }

public int Port { get; }
internal string Host { get; }

public NetworkCredential Credentials { get; }
internal int Port { get; }

public ProxySettings Settings { get; }
internal NetworkCredential Credentials { get; }

internal HttpClient GetHttpClient()
{
Expand All @@ -65,7 +65,7 @@ internal HttpClient GetHttpClient()

private HttpMessageHandler GetHttpMessageHandler()
{
if (Settings.Protocol == ProxyProtocol.HTTP)
if (Settings.Protocol == ProxyProtocol.Http)
{
return new HttpClientHandler()
{
Expand All @@ -88,19 +88,19 @@ private HttpMessageHandler GetHttpMessageHandler()

return Settings.Protocol switch
{
ProxyProtocol.SOCKS4 => new ProxyClientHandler<Socks4>(proxySettings)
ProxyProtocol.Socks4 => new ProxyClientHandler<Socks4>(proxySettings)
{
AllowAutoRedirect = Settings.AllowAutoRedirect,
UseCookies = Settings.UseCookies,
CookieContainer = Settings.CookieContainer
},
ProxyProtocol.SOCKS4a => new ProxyClientHandler<Socks4a>(proxySettings)
ProxyProtocol.Socks4A => new ProxyClientHandler<Socks4a>(proxySettings)
{
AllowAutoRedirect = Settings.AllowAutoRedirect,
UseCookies = Settings.UseCookies,
CookieContainer = Settings.CookieContainer
},
ProxyProtocol.SOCKS5 => new ProxyClientHandler<Socks5>(proxySettings)
ProxyProtocol.Socks5 => new ProxyClientHandler<Socks5>(proxySettings)
{
AllowAutoRedirect = Settings.AllowAutoRedirect,
UseCookies = Settings.UseCookies,
Expand Down

0 comments on commit 53d95b1

Please sign in to comment.