Skip to content

Commit cf776b9

Browse files
committed
Added proxy authentication
1 parent 6d9433a commit cf776b9

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ all websites as if they're not protected with anything.
4343
var handler = new ClearanceHandler("http://localhost:8191/")
4444
{
4545
MaxTimeout = 60000,
46-
ProxyUrl = "http://127.0.0.1:8888"
46+
ProxyUrl = "http://127.0.0.1:8888",
47+
ProxyUsername = "cool_username",
48+
ProxyPassword = "password4"
4749
};
4850

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

7375
Example: http://127.0.0.1:8888
76+
77+
### ProxyUsername
78+
The ProxyUsername which will be sent to FlareSolverr. (Only if ProxyUrl has been set)
79+
80+
Use this if the proxy you're using requires authentication.
81+
82+
### ProxyPassword
83+
The ProxyPassword which will be sent to FlareSolverr. (Only if ProxyUrl has been set)
84+
85+
Use this if the proxy you're using requires authentication.

src/FlareSolverrSharp/ClearanceHandler.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ public class ClearanceHandler : DelegatingHandler
3434
/// </summary>
3535
public string ProxyUrl = "";
3636

37+
/// <summary>
38+
/// HTTP Proxy Username.
39+
/// </summary>
40+
public string ProxyUsername = "";
41+
42+
/// <summary>
43+
/// HTTP Proxy Password.
44+
/// </summary>
45+
public string ProxyPassword = "";
46+
3747
private HttpClientHandler HttpClientHandler => InnerHandler.GetMostInnerHandler() as HttpClientHandler;
3848

3949
/// <summary>
@@ -73,7 +83,9 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
7383
_flareSolverr = new FlareSolverr(_flareSolverrApiUrl)
7484
{
7585
MaxTimeout = MaxTimeout,
76-
ProxyUrl = ProxyUrl
86+
ProxyUrl = ProxyUrl,
87+
ProxyUsername = ProxyUsername,
88+
ProxyPassword = ProxyPassword
7789
};
7890
}
7991

src/FlareSolverrSharp/Solvers/FlareSolverr.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class FlareSolverr
1818

1919
public int MaxTimeout = 60000;
2020
public string ProxyUrl = "";
21+
public string ProxyUsername = "";
22+
public string ProxyPassword = "";
2123

2224
public FlareSolverr(string flareSolverrApiUrl)
2325
{
@@ -152,7 +154,9 @@ private FlareSolverrRequestProxy GetProxy()
152154
{
153155
proxy = new FlareSolverrRequestProxy
154156
{
155-
Url = ProxyUrl
157+
Url = ProxyUrl,
158+
Username = ProxyUsername,
159+
Password = ProxyPassword
156160
};
157161
}
158162
return proxy;
@@ -225,4 +229,4 @@ private HttpContent GenerateFlareSolverrRequest(HttpRequestMessage request, stri
225229
}
226230

227231
}
228-
}
232+
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
using Newtonsoft.Json;
1+
using System.ComponentModel;
2+
using Newtonsoft.Json;
23

34
namespace FlareSolverrSharp.Types
45
{
56
public class FlareSolverrRequestProxy
67
{
78
[JsonProperty("url")]
89
public string Url;
10+
11+
[DefaultValue("")]
12+
[JsonProperty("username", DefaultValueHandling = DefaultValueHandling.Ignore)]
13+
public string Username;
14+
15+
[DefaultValue("")]
16+
[JsonProperty("password", DefaultValueHandling = DefaultValueHandling.Ignore)]
17+
public string Password;
918
}
1019
}

0 commit comments

Comments
 (0)