diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
new file mode 100644
index 0000000..0e4f215
--- /dev/null
+++ b/.github/workflows/dotnet.yml
@@ -0,0 +1,31 @@
+name: Publish .NET Package
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: '7.0.x' # Change this to the .NET version you are using
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: Build
+ run: dotnet build --configuration Release --no-restore
+ - name: Test
+ run: dotnet test --no-restore --verbosity normal
+ - name: Publish
+ run: dotnet pack --configuration Release --no-build --output ./artifacts
+ - name: Push to GitHub Packages
+ run: dotnet nuget push ./artifacts/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/top-gg/index.json --skip-duplicate
+
+env:
+ DOTNET_NOLOGO: true
+ DOTNET_CLI_TELEMETRY_OPTOUT: true
diff --git a/ProxyCheck/IProxyChceckCacheProvider.cs b/ProxyCheck/IProxyCheckCacheProvider.cs
similarity index 90%
rename from ProxyCheck/IProxyChceckCacheProvider.cs
rename to ProxyCheck/IProxyCheckCacheProvider.cs
index 00fdbca..24539f1 100644
--- a/ProxyCheck/IProxyChceckCacheProvider.cs
+++ b/ProxyCheck/IProxyCheckCacheProvider.cs
@@ -3,7 +3,7 @@
namespace ProxyCheckUtil
{
- public interface IProxyChceckCacheProvider
+ public interface IProxyCheckCacheProvider
{
ProxyCheckResult.IpResult GetCacheRecord(IPAddress ip, ProxyCheckRequestOptions options);
diff --git a/ProxyCheck/ProxyCheck.cs b/ProxyCheck/ProxyCheck.cs
index 2cd58c2..61f37c1 100644
--- a/ProxyCheck/ProxyCheck.cs
+++ b/ProxyCheck/ProxyCheck.cs
@@ -47,7 +47,7 @@ public class ProxyCheck
///
/// API key to use
/// Cache provider to use
- public ProxyCheck(string apiKey = "", IProxyChceckCacheProvider cacheProvider = null)
+ public ProxyCheck(string apiKey = "", IProxyCheckCacheProvider cacheProvider = null)
{
if (apiKey == null)
apiKey = string.Empty;
@@ -56,17 +56,16 @@ public ProxyCheck(string apiKey = "", IProxyChceckCacheProvider cacheProvider =
CacheProvider = cacheProvider;
}
- public ProxyCheck(IProxyChceckCacheProvider cacheProvider)
+ public ProxyCheck(IProxyCheckCacheProvider cacheProvider)
{
CacheProvider = cacheProvider;
}
- private const string PROXYCHECKURL = "proxycheck.io/v2";
+ private const string ProxyCheckUrl = "proxycheck.io/v2";
private ProxyCheckRequestOptions _options = new ProxyCheckRequestOptions();
-
-
- public IProxyChceckCacheProvider CacheProvider { get; set; }
+
+ public IProxyCheckCacheProvider CacheProvider { get; set; }
///
/// The API key to use with the query
@@ -158,7 +157,16 @@ public bool IncludeLastSeen
///
public int DayLimit { get; set; } = 7;
-
+ ///
+ /// Determines whether you will receive a risk score with the result. If enabled, a risk score will be included
+ /// with your response.
+ /// (Default: )
+ ///
+ public RiskLevel RiskLevel
+ {
+ get => _options.RiskLevel ?? RiskLevel.Disabled;
+ set => _options.RiskLevel = value;
+ }
///
@@ -274,7 +282,7 @@ public async Task QueryAsync(IPAddress[] ipAddresses, string t
}
var url = new StringBuilder()
- .Append($"{(UseTLS ? "https://" : "http://")}{PROXYCHECKURL}/")
+ .Append($"{(UseTLS ? "https://" : "http://")}{ProxyCheckUrl}/")
.Append(!string.IsNullOrWhiteSpace(ApiKey) ? $"&key={ApiKey}" : "")
.Append($"&vpn={Convert.ToInt32(IncludeVPN)}")
.Append($"&asn={Convert.ToInt32(IncludeASN)}")
@@ -283,7 +291,8 @@ public async Task QueryAsync(IPAddress[] ipAddresses, string t
.Append($"&inf={Convert.ToInt32(UseInference)}")
.Append($"&port={Convert.ToInt32(IncludePort)}")
.Append($"&seen={Convert.ToInt32(IncludeLastSeen)}")
- .Append($"&days={Convert.ToInt32(DayLimit)}");
+ .Append($"&days={Convert.ToInt32(DayLimit)}")
+ .Append($"&risk={Convert.ToInt32(RiskLevel)}");
using (var client = new HttpClient())
{
@@ -412,7 +421,11 @@ private ProxyCheckResult ParseJson(string json)
string isProxy = (string) innerToken.Value;
ipResult.IsProxy = isProxy.Equals("yes", StringComparison.OrdinalIgnoreCase);
break;
-
+
+ case "risk":
+ ipResult.RiskScore = Convert.ToInt32((string)innerToken.Value);
+ break;
+
case "type":
ipResult.ProxyType = (string)innerToken.Value;
break;
diff --git a/ProxyCheck/ProxyCheckRequestOptions.cs b/ProxyCheck/ProxyCheckRequestOptions.cs
index 3284eb5..837cfe8 100644
--- a/ProxyCheck/ProxyCheckRequestOptions.cs
+++ b/ProxyCheck/ProxyCheckRequestOptions.cs
@@ -41,6 +41,13 @@ public class ProxyCheckRequestOptions
///
public bool IncludeLastSeen { get; set; }
+ ///
+ /// Determines whether you will receive a risk score with the result. If enabled, a risk score will be included
+ /// with your response.
+ /// (Default: )
+ ///
+ public RiskLevel? RiskLevel { get; set; }
+
public override bool Equals(object obj)
{
if (!(obj is ProxyCheckRequestOptions o))
@@ -61,6 +68,9 @@ public override bool Equals(object obj)
if (IncludePort != o.IncludePort)
return false;
+ if (RiskLevel != o.RiskLevel)
+ return false;
+
return IncludeLastSeen == o.IncludeLastSeen;
}
}
diff --git a/ProxyCheck/ProxyCheckResult.cs b/ProxyCheck/ProxyCheckResult.cs
index 5313652..9a7cbb7 100644
--- a/ProxyCheck/ProxyCheckResult.cs
+++ b/ProxyCheck/ProxyCheckResult.cs
@@ -116,6 +116,11 @@ public class IpResult
///
public int? Port { get; set; }
+ ///
+ /// Not null when risk is > 0, the risk score of the IP address
+ ///
+ public int? RiskScore { get; set; }
+
///
/// The last time the proxy server was seen in human readable format.
///
diff --git a/ProxyCheck/RiskLevel.cs b/ProxyCheck/RiskLevel.cs
new file mode 100644
index 0000000..6716903
--- /dev/null
+++ b/ProxyCheck/RiskLevel.cs
@@ -0,0 +1,9 @@
+namespace ProxyCheckUtil
+{
+ public enum RiskLevel
+ {
+ Disabled = 0,
+ Enable = 1,
+ EnableWithAttackData = 2
+ }
+}
\ No newline at end of file
diff --git a/ProxyCheck/SimpleInMemoryCache.cs b/ProxyCheck/SimpleInMemoryCache.cs
index ec918d3..7a2f9d2 100644
--- a/ProxyCheck/SimpleInMemoryCache.cs
+++ b/ProxyCheck/SimpleInMemoryCache.cs
@@ -5,7 +5,7 @@
namespace ProxyCheckUtil
{
- public class SimpleInMemoryCache : IProxyChceckCacheProvider
+ public class SimpleInMemoryCache : IProxyCheckCacheProvider
{
private List _cacheItems = new List();
private TimeSpan _maxCacheAge = TimeSpan.FromHours(1);