Skip to content

Commit edacaec

Browse files
committed
Added support for fraud score
1 parent c8acd91 commit edacaec

File tree

6 files changed

+74
-21
lines changed

6 files changed

+74
-21
lines changed

IP2ProxyComponent/IP2ProxyComponent/IP2Proxy.vb

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Public Structure ProxyResult
2222
Public Last_Seen As String
2323
Public Threat As String
2424
Public Provider As String
25+
Public Fraud_Score As String
2526
End Structure
2627

2728
Public Class Component
@@ -102,21 +103,23 @@ Public Class Component
102103
LAST_SEEN = 12
103104
THREAT = 13
104105
PROVIDER = 14
106+
FRAUD_SCORE = 15
105107
ALL = 100
106108
End Enum
107109

108-
Private ReadOnly COUNTRY_POSITION() As Byte = {0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
109-
Private ReadOnly REGION_POSITION() As Byte = {0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4}
110-
Private ReadOnly CITY_POSITION() As Byte = {0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5}
111-
Private ReadOnly ISP_POSITION() As Byte = {0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6}
112-
Private ReadOnly PROXYTYPE_POSITION() As Byte = {0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
113-
Private ReadOnly DOMAIN_POSITION() As Byte = {0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7}
114-
Private ReadOnly USAGETYPE_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8}
115-
Private ReadOnly ASN_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9}
116-
Private ReadOnly AS_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10}
117-
Private ReadOnly LASTSEEN_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11}
118-
Private ReadOnly THREAT_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12}
119-
Private ReadOnly PROVIDER_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13}
110+
Private ReadOnly COUNTRY_POSITION() As Byte = {0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
111+
Private ReadOnly REGION_POSITION() As Byte = {0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}
112+
Private ReadOnly CITY_POSITION() As Byte = {0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}
113+
Private ReadOnly ISP_POSITION() As Byte = {0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6}
114+
Private ReadOnly PROXYTYPE_POSITION() As Byte = {0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
115+
Private ReadOnly DOMAIN_POSITION() As Byte = {0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7}
116+
Private ReadOnly USAGETYPE_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8}
117+
Private ReadOnly ASN_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9}
118+
Private ReadOnly AS_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10}
119+
Private ReadOnly LASTSEEN_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11}
120+
Private ReadOnly THREAT_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12}
121+
Private ReadOnly PROVIDER_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13}
122+
Private ReadOnly FRAUDSCORE_POSITION() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14}
120123

121124
Private COUNTRY_POSITION_OFFSET As Integer = 0
122125
Private REGION_POSITION_OFFSET As Integer = 0
@@ -130,6 +133,7 @@ Public Class Component
130133
Private LASTSEEN_POSITION_OFFSET As Integer = 0
131134
Private THREAT_POSITION_OFFSET As Integer = 0
132135
Private PROVIDER_POSITION_OFFSET As Integer = 0
136+
Private FRAUDSCORE_POSITION_OFFSET As Integer = 0
133137

134138
Private COUNTRY_ENABLED As Boolean = False
135139
Private REGION_ENABLED As Boolean = False
@@ -143,6 +147,7 @@ Public Class Component
143147
Private LASTSEEN_ENABLED As Boolean = False
144148
Private THREAT_ENABLED As Boolean = False
145149
Private PROVIDER_ENABLED As Boolean = False
150+
Private FRAUDSCORE_ENABLED As Boolean = False
146151

147152
'Description: Returns the module version
148153
Public Shared Function GetModuleVersion() As String
@@ -312,6 +317,16 @@ Public Class Component
312317
Return (Await ProxyQueryAsync(IP, Modes.PROVIDER)).Provider
313318
End Function
314319

320+
'Description: Returns a string for the fraud score
321+
Public Function GetFraudScore(IP As String) As String
322+
Return ProxyQuery(IP, Modes.FRAUD_SCORE).Fraud_Score
323+
End Function
324+
325+
'Description: Returns a string for the fraud score (async)
326+
Public Async Function GetFraudScoreAsync(IP As String) As Task(Of String)
327+
Return (Await ProxyQueryAsync(IP, Modes.FRAUD_SCORE)).Fraud_Score
328+
End Function
329+
315330
'Description: Returns all results
316331
Public Function GetAll(IP As String) As ProxyResult
317332
Return ProxyQuery(IP)
@@ -463,6 +478,7 @@ Public Class Component
463478
LASTSEEN_POSITION_OFFSET = If(LASTSEEN_POSITION(_DBType) <> 0, (LASTSEEN_POSITION(_DBType) - 2) << 2, 0)
464479
THREAT_POSITION_OFFSET = If(THREAT_POSITION(_DBType) <> 0, (THREAT_POSITION(_DBType) - 2) << 2, 0)
465480
PROVIDER_POSITION_OFFSET = If(PROVIDER_POSITION(_DBType) <> 0, (PROVIDER_POSITION(_DBType) - 2) << 2, 0)
481+
FRAUDSCORE_POSITION_OFFSET = If(FRAUDSCORE_POSITION(_DBType) <> 0, (FRAUDSCORE_POSITION(_DBType) - 2) << 2, 0)
466482

467483
COUNTRY_ENABLED = COUNTRY_POSITION(_DBType) <> 0
468484
REGION_ENABLED = REGION_POSITION(_DBType) <> 0
@@ -476,6 +492,7 @@ Public Class Component
476492
LASTSEEN_ENABLED = LASTSEEN_POSITION(_DBType) <> 0
477493
THREAT_ENABLED = THREAT_POSITION(_DBType) <> 0
478494
PROVIDER_ENABLED = PROVIDER_POSITION(_DBType) <> 0
495+
FRAUDSCORE_ENABLED = FRAUDSCORE_POSITION(_DBType) <> 0
479496

480497
Dim readLen = _IndexArrayIPv4.GetLength(0)
481498
If _IndexBaseAddrIPv6 > 0 Then
@@ -620,6 +637,7 @@ Public Class Component
620637
.Last_Seen = MSG_INVALID_IP
621638
.Threat = MSG_INVALID_IP
622639
.Provider = MSG_INVALID_IP
640+
.Fraud_Score = MSG_INVALID_IP
623641
End With
624642
Return Result
625643
End If
@@ -643,6 +661,7 @@ Public Class Component
643661
.Last_Seen = MSG_INVALID_IP
644662
.Threat = MSG_INVALID_IP
645663
.Provider = MSG_INVALID_IP
664+
.Fraud_Score = MSG_INVALID_IP
646665
End With
647666
Return Result
648667
End If
@@ -665,6 +684,7 @@ Public Class Component
665684
.Last_Seen = MSG_MISSING_FILE
666685
.Threat = MSG_MISSING_FILE
667686
.Provider = MSG_MISSING_FILE
687+
.Fraud_Score = MSG_MISSING_FILE
668688
End With
669689
Return Result
670690
End If
@@ -714,6 +734,7 @@ Public Class Component
714734
.Last_Seen = MSG_IPV6_UNSUPPORTED
715735
.Threat = MSG_IPV6_UNSUPPORTED
716736
.Provider = MSG_IPV6_UNSUPPORTED
737+
.Fraud_Score = MSG_IPV6_UNSUPPORTED
717738
End With
718739
Return Result
719740
End If
@@ -771,6 +792,7 @@ Public Class Component
771792
Dim Last_Seen As String = MSG_NOT_SUPPORTED
772793
Dim Threat As String = MSG_NOT_SUPPORTED
773794
Dim Provider As String = MSG_NOT_SUPPORTED
795+
Dim Fraud_Score As String = MSG_NOT_SUPPORTED
774796

775797
Dim RowLen = ColumnSize - FirstCol
776798

@@ -847,6 +869,11 @@ Public Class Component
847869
Provider = ReadStr(Read32Row(Row, PROVIDER_POSITION_OFFSET), FS)
848870
End If
849871
End If
872+
If FRAUDSCORE_ENABLED Then
873+
If Mode = Modes.ALL OrElse Mode = Modes.FRAUD_SCORE Then
874+
Fraud_Score = ReadStr(Read32Row(Row, FRAUDSCORE_POSITION_OFFSET), FS)
875+
End If
876+
End If
850877

851878
If Country_Short = "-" OrElse Proxy_Type = "-" Then
852879
Is_Proxy = 0
@@ -873,6 +900,7 @@ Public Class Component
873900
.Last_Seen = Last_Seen
874901
.Threat = Threat
875902
.Provider = Provider
903+
.Fraud_Score = Fraud_Score
876904
End With
877905
Return Result
878906
Else
@@ -899,6 +927,7 @@ Public Class Component
899927
.Last_Seen = MSG_INVALID_IP
900928
.Threat = MSG_INVALID_IP
901929
.Provider = MSG_INVALID_IP
930+
.Fraud_Score = MSG_INVALID_IP
902931
End With
903932
Return Result
904933
Finally
@@ -954,6 +983,7 @@ Public Class Component
954983
.Last_Seen = MSG_INVALID_IP
955984
.Threat = MSG_INVALID_IP
956985
.Provider = MSG_INVALID_IP
986+
.Fraud_Score = MSG_INVALID_IP
957987
End With
958988
Return Result
959989
End If
@@ -977,6 +1007,7 @@ Public Class Component
9771007
.Last_Seen = MSG_INVALID_IP
9781008
.Threat = MSG_INVALID_IP
9791009
.Provider = MSG_INVALID_IP
1010+
.Fraud_Score = MSG_INVALID_IP
9801011
End With
9811012
Return Result
9821013
End If
@@ -999,6 +1030,7 @@ Public Class Component
9991030
.Last_Seen = MSG_MISSING_FILE
10001031
.Threat = MSG_MISSING_FILE
10011032
.Provider = MSG_MISSING_FILE
1033+
.Fraud_Score = MSG_MISSING_FILE
10021034
End With
10031035
Return Result
10041036
End If
@@ -1053,6 +1085,7 @@ Public Class Component
10531085
.Last_Seen = MSG_IPV6_UNSUPPORTED
10541086
.Threat = MSG_IPV6_UNSUPPORTED
10551087
.Provider = MSG_IPV6_UNSUPPORTED
1088+
.Fraud_Score = MSG_IPV6_UNSUPPORTED
10561089
End With
10571090
Return Result
10581091
End If
@@ -1110,6 +1143,7 @@ Public Class Component
11101143
Dim Last_Seen As String = MSG_NOT_SUPPORTED
11111144
Dim Threat As String = MSG_NOT_SUPPORTED
11121145
Dim Provider As String = MSG_NOT_SUPPORTED
1146+
Dim Fraud_Score As String = MSG_NOT_SUPPORTED
11131147

11141148
Dim RowLen = ColumnSize - FirstCol
11151149

@@ -1186,6 +1220,11 @@ Public Class Component
11861220
Provider = Await ReadStrAsync(Read32Row(Row, PROVIDER_POSITION_OFFSET), myRef)
11871221
End If
11881222
End If
1223+
If FRAUDSCORE_ENABLED Then
1224+
If Mode = Modes.ALL OrElse Mode = Modes.FRAUD_SCORE Then
1225+
Fraud_Score = Await ReadStrAsync(Read32Row(Row, FRAUDSCORE_POSITION_OFFSET), myRef)
1226+
End If
1227+
End If
11891228

11901229
If Country_Short = "-" OrElse Proxy_Type = "-" Then
11911230
Is_Proxy = 0
@@ -1212,6 +1251,7 @@ Public Class Component
12121251
.Last_Seen = Last_Seen
12131252
.Threat = Threat
12141253
.Provider = Provider
1254+
.Fraud_Score = Fraud_Score
12151255
End With
12161256
Return Result
12171257
Else
@@ -1238,6 +1278,7 @@ Public Class Component
12381278
.Last_Seen = MSG_INVALID_IP
12391279
.Threat = MSG_INVALID_IP
12401280
.Provider = MSG_INVALID_IP
1281+
.Fraud_Score = MSG_INVALID_IP
12411282
End With
12421283
Return Result
12431284
Finally

IP2ProxyComponent/IP2ProxyComponent/IP2ProxyComponent.vbproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<RootNamespace>IP2Proxy</RootNamespace>
55
<TargetFrameworks>netstandard2.0;net472;net48;net481;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
66
<AssemblyName>IP2Proxy</AssemblyName>
7-
<Version>4.0.3</Version>
7+
<Version>4.1.0</Version>
88
<Authors>IP2Proxy.com</Authors>
99
<Company>IP2Proxy.com</Company>
1010
<Product>IP2Proxy .NET Component</Product>
1111
<Title>IP2Proxy .NET Component</Title>
1212
<Description>IP2Proxy .NET Component</Description>
1313
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
14-
<Copyright>Copyright 2024</Copyright>
14+
<Copyright>Copyright 2025</Copyright>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1616
<PackageProjectUrl>https://www.ip2location.com/development-libraries/ip2proxy/dot-net</PackageProjectUrl>
1717
<PackageIcon>ip2proxy-logo-square-128.png</PackageIcon>
18-
<PackageReleaseNotes>Updated for compatibility with .NET 8</PackageReleaseNotes>
18+
<PackageReleaseNotes>Added support for fraud score</PackageReleaseNotes>
1919
<RepositoryUrl>https://github.com/ip2location/ip2proxy-dotnet.git</RepositoryUrl>
2020
<PackageTags>ip2proxy proxy detection</PackageTags>
2121
<RepositoryType>git</RepositoryType>

LICENSE.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 - 2024 IP2Location.com
3+
Copyright (c) 2017 - 2025 IP2Location.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/source/code.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Close and clean up the file pointer.
1919
```
2020

2121
```{py:function} GetPackageVersion()
22-
Return the database's type, 1 to 11 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details.
22+
Return the database's type, 1 to 12 respectively for PX1 to PX12. Please visit https://www.ip2location.com/databases/ip2proxy for details.
2323
2424
:return: Returns the package version.
2525
:rtype: String
@@ -63,6 +63,7 @@ Retrieve geolocation information for an IP address.
6363
| Threat | Security threat reported. |
6464
| Proxy_Type | Type of proxy. |
6565
| Provider | Name of VPN provider if available. |
66+
| Fraud_Score | Potential risk score (0 - 99) associated with IP address. |
6667
```
6768

6869
```{py:function} GetAllAsync(IP)
@@ -89,4 +90,5 @@ Retrieve geolocation information for an IP address.
8990
| Threat | Security threat reported. |
9091
| Proxy_Type | Type of proxy. |
9192
| Provider | Name of VPN provider if available. |
93+
| Fraud_Score | Potential risk score (0 - 99) associated with IP address. |
9294
```

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# -- Project information
55

66
project = 'IP2Proxy .NET'
7-
copyright = '2024, IP2Location'
7+
copyright = '2025, IP2Location'
88
author = 'IP2Location'
99

1010
release = '0.1.0'
@@ -57,4 +57,4 @@
5757

5858
html_title = "IP2Proxy .NET"
5959

60-
# html_baseurl = "https://ip2proxy-go.readthedocs.io/en/latest/"
60+
# html_baseurl = "https://ip2proxy-dotnet.readthedocs.io/en/latest/"

docs/source/quickstart.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ Dim [as] As String
4141
Dim lastseen As String
4242
Dim threat As String
4343
Dim provider As String
44+
Dim fraudscore As String
4445

4546
Dim ip As String = "221.121.146.0"
4647

47-
If proxy.Open("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN", Component.IOModes.IP2PROXY_MEMORY_MAPPED) = 0 Then
48+
If proxy.Open("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE.BIN", Component.IOModes.IP2PROXY_MEMORY_MAPPED) = 0 Then
4849
Console.WriteLine("GetModuleVersion: " & Component.GetModuleVersion())
4950
Console.WriteLine("GetPackageVersion: " & proxy.GetPackageVersion())
5051
Console.WriteLine("GetDatabaseVersion: " & proxy.GetDatabaseVersion())
@@ -65,6 +66,7 @@ If proxy.Open("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAG
6566
Console.WriteLine("Last_Seen: " & all.Last_Seen)
6667
Console.WriteLine("Threat: " & all.Threat)
6768
Console.WriteLine("Provider: " & all.Provider)
69+
Console.WriteLine("Fraud_Score: " & all.Fraud_Score)
6870

6971
' reading individual fields
7072
isproxy = proxy.IsProxy(ip)
@@ -108,6 +110,9 @@ If proxy.Open("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAG
108110

109111
provider = proxy.GetProvider(ip)
110112
Console.WriteLine("Provider: " & provider)
113+
114+
fraudscore = proxy.GetFraudScore(ip)
115+
Console.WriteLine("Fraud_Score: " & fraudscore)
111116
Else
112117
Console.WriteLine("Error reading BIN file.")
113118
End If
@@ -139,10 +144,11 @@ Dim [as] As String
139144
Dim lastseen As String
140145
Dim threat As String
141146
Dim provider As String
147+
Dim fraudscore As String
142148

143149
Dim ip As String = "221.121.146.0"
144150

145-
Using myStream = New FileStream("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN", FileMode.Open, FileAccess.Read, FileShare.Read)
151+
Using myStream = New FileStream("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE.BIN", FileMode.Open, FileAccess.Read, FileShare.Read)
146152
If proxy.Open(myStream) = 0 Then
147153
Console.WriteLine("GetModuleVersion: " & Component.GetModuleVersion())
148154
Console.WriteLine("GetPackageVersion: " & proxy.GetPackageVersion())
@@ -164,6 +170,7 @@ Using myStream = New FileStream("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CI
164170
Console.WriteLine("Last_Seen: " & all.Last_Seen)
165171
Console.WriteLine("Threat: " & all.Threat)
166172
Console.WriteLine("Provider: " & all.Provider)
173+
Console.WriteLine("Fraud_Score: " & all.Fraud_Score)
167174

168175
' reading individual fields
169176
isproxy = proxy.IsProxyAsync(ip).Result
@@ -207,6 +214,9 @@ Using myStream = New FileStream("C:\data\IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CI
207214

208215
provider = proxy.GetProviderAsync(ip).Result
209216
Console.WriteLine("Provider: " & provider)
217+
218+
fraudscore = proxy.GetFraudScoreAsync(ip).Result
219+
Console.WriteLine("Fraud_Score: " & fraudscore)
210220
Else
211221
Console.WriteLine("Error reading BIN file.")
212222
End If

0 commit comments

Comments
 (0)