Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ all websites as if they're not protected with anything.
var handler = new ClearanceHandler("http://localhost:8191/")
{
MaxTimeout = 60000,
ProxyUrl = "http://127.0.0.1:8888"
ProxyUrl = "http://127.0.0.1:8888",
ProxyUsername = "cool_username",
ProxyPassword = "password4"
};

var client = new HttpClient(handler);
Expand Down Expand Up @@ -71,3 +73,13 @@ Example: 60000
The ProxyUrl which will be sent to FlareSolverr.

Example: http://127.0.0.1:8888

### ProxyUsername
The ProxyUsername which will be sent to FlareSolverr. (Only if ProxyUrl has been set)

Use this if the proxy you're using requires authentication.

### ProxyPassword
The ProxyPassword which will be sent to FlareSolverr. (Only if ProxyUrl has been set)

Use this if the proxy you're using requires authentication.
14 changes: 13 additions & 1 deletion src/FlareSolverrSharp/ClearanceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public class ClearanceHandler : DelegatingHandler
/// </summary>
public string ProxyUrl = "";

/// <summary>
/// HTTP Proxy Username.
/// </summary>
public string ProxyUsername = null;

/// <summary>
/// HTTP Proxy Password.
/// </summary>
public string ProxyPassword = null;

private HttpClientHandler HttpClientHandler => InnerHandler.GetMostInnerHandler() as HttpClientHandler;

/// <summary>
Expand Down Expand Up @@ -73,7 +83,9 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
_flareSolverr = new FlareSolverr(_flareSolverrApiUrl)
{
MaxTimeout = MaxTimeout,
ProxyUrl = ProxyUrl
ProxyUrl = ProxyUrl,
ProxyUsername = ProxyUsername,
ProxyPassword = ProxyPassword
};
}

Expand Down
18 changes: 14 additions & 4 deletions src/FlareSolverrSharp/Solvers/FlareSolverr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class FlareSolverr

public int MaxTimeout = 60000;
public string ProxyUrl = "";
public string ProxyUsername = null;
public string ProxyPassword = null;

public FlareSolverr(string flareSolverrApiUrl)
{
Expand Down Expand Up @@ -152,7 +154,15 @@ private FlareSolverrRequestProxy GetProxy()
{
proxy = new FlareSolverrRequestProxy
{
Url = ProxyUrl
Url = ProxyUrl,
};
if (!string.IsNullOrWhiteSpace(ProxyUsername)
{
proxy.Username = ProxyUsername;
};
if (!string.IsNullOrWhiteSpace(ProxyPassword))
{
proxy.Password = ProxyPassword;
};
}
return proxy;
Expand All @@ -172,7 +182,7 @@ private HttpContent GenerateFlareSolverrRequest(HttpRequestMessage request, stri
{
FlareSolverrRequest req;
if (string.IsNullOrWhiteSpace(sessionId))
sessionId = null;
sessionId = null;

var url = request.RequestUri.ToString();

Expand Down Expand Up @@ -223,6 +233,6 @@ private HttpContent GenerateFlareSolverrRequest(HttpRequestMessage request, stri

return GetSolverRequestContent(req);
}

}
}
}
6 changes: 6 additions & 0 deletions src/FlareSolverrSharp/Types/FlareSolverrRequestProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@ public class FlareSolverrRequestProxy
{
[JsonProperty("url")]
public string Url;

[JsonProperty("username")]
public string Username;

[JsonProperty("password")]
public string Password;
}
}