1- #region
2-
31using System ;
42using System . Text . Json . Serialization ;
53
6- #endregion
7-
84namespace MaxMind . GeoIP2 . Model
95{
106 /// <summary>
117 /// Contains anonymizer-related data associated with an IP address.
128 /// This data is available from the GeoIP2 Insights web service.
139 /// </summary>
14- public class Anonymizer
10+ public record Anonymizer
1511 {
16- /// <summary>
17- /// Constructor
18- /// </summary>
19- public Anonymizer ( )
20- {
21- }
22-
23- /// <summary>
24- /// Constructor
25- /// </summary>
26- public Anonymizer (
27- int ? confidence = null ,
28- bool isAnonymous = false ,
29- bool isAnonymousVpn = false ,
30- bool isHostingProvider = false ,
31- bool isPublicProxy = false ,
32- bool isResidentialProxy = false ,
33- bool isTorExitNode = false ,
34- #if NET6_0_OR_GREATER
35- DateOnly ? networkLastSeen = null ,
36- #endif
37- string ? providerName = null
38- )
39- {
40- Confidence = confidence ;
41- IsAnonymous = isAnonymous ;
42- IsAnonymousVpn = isAnonymousVpn ;
43- IsHostingProvider = isHostingProvider ;
44- IsPublicProxy = isPublicProxy ;
45- IsResidentialProxy = isResidentialProxy ;
46- IsTorExitNode = isTorExitNode ;
47- #if NET6_0_OR_GREATER
48- NetworkLastSeen = networkLastSeen ;
49- #endif
50- ProviderName = providerName ;
51- }
52-
5312 /// <summary>
5413 /// A score ranging from 1 to 99 that represents our percent confidence
5514 /// that the network is currently part of an actively used VPN service.
5615 /// This is available from the GeoIP2 Insights web service.
5716 /// </summary>
5817 [ JsonInclude ]
5918 [ JsonPropertyName ( "confidence" ) ]
60- public int ? Confidence { get ; internal set ; }
19+ public int ? Confidence { get ; init ; }
6120
6221 /// <summary>
6322 /// This is true if the IP address belongs to any sort of anonymous
6423 /// network. This is available from the GeoIP2 Insights web service.
6524 /// </summary>
6625 [ JsonInclude ]
6726 [ JsonPropertyName ( "is_anonymous" ) ]
68- public bool IsAnonymous { get ; internal set ; }
27+ public bool IsAnonymous { get ; init ; }
6928
7029 /// <summary>
7130 /// This is true if the IP address is registered to an anonymous
@@ -79,7 +38,7 @@ public Anonymizer(
7938 /// </remarks>
8039 [ JsonInclude ]
8140 [ JsonPropertyName ( "is_anonymous_vpn" ) ]
82- public bool IsAnonymousVpn { get ; internal set ; }
41+ public bool IsAnonymousVpn { get ; init ; }
8342
8443 /// <summary>
8544 /// This is true if the IP address belongs to a hosting or VPN
@@ -88,15 +47,15 @@ public Anonymizer(
8847 /// </summary>
8948 [ JsonInclude ]
9049 [ JsonPropertyName ( "is_hosting_provider" ) ]
91- public bool IsHostingProvider { get ; internal set ; }
50+ public bool IsHostingProvider { get ; init ; }
9251
9352 /// <summary>
9453 /// This is true if the IP address belongs to a public proxy.
9554 /// This is available from the GeoIP2 Insights web service.
9655 /// </summary>
9756 [ JsonInclude ]
9857 [ JsonPropertyName ( "is_public_proxy" ) ]
99- public bool IsPublicProxy { get ; internal set ; }
58+ public bool IsPublicProxy { get ; init ; }
10059
10160 /// <summary>
10261 /// This is true if the IP address is on a suspected anonymizing
@@ -105,15 +64,15 @@ public Anonymizer(
10564 /// </summary>
10665 [ JsonInclude ]
10766 [ JsonPropertyName ( "is_residential_proxy" ) ]
108- public bool IsResidentialProxy { get ; internal set ; }
67+ public bool IsResidentialProxy { get ; init ; }
10968
11069 /// <summary>
11170 /// This is true if the IP address belongs to a Tor exit node.
11271 /// This is available from the GeoIP2 Insights web service.
11372 /// </summary>
11473 [ JsonInclude ]
11574 [ JsonPropertyName ( "is_tor_exit_node" ) ]
116- public bool IsTorExitNode { get ; internal set ; }
75+ public bool IsTorExitNode { get ; init ; }
11776
11877#if NET6_0_OR_GREATER
11978 /// <summary>
@@ -123,7 +82,7 @@ public Anonymizer(
12382 /// </summary>
12483 [ JsonInclude ]
12584 [ JsonPropertyName ( "network_last_seen" ) ]
126- public DateOnly ? NetworkLastSeen { get ; internal set ; }
85+ public DateOnly ? NetworkLastSeen { get ; init ; }
12786#endif
12887
12988 /// <summary>
@@ -133,27 +92,6 @@ public Anonymizer(
13392 /// </summary>
13493 [ JsonInclude ]
13594 [ JsonPropertyName ( "provider_name" ) ]
136- public string ? ProviderName { get ; internal set ; }
137-
138- /// <summary>
139- /// Returns a <see cref="string" /> that represents this instance.
140- /// </summary>
141- /// <returns>
142- /// A <see cref="string" /> that represents this instance.
143- /// </returns>
144- public override string ToString ( )
145- {
146- return $ "{ nameof ( Confidence ) } : { Confidence } , " +
147- $ "{ nameof ( IsAnonymous ) } : { IsAnonymous } , " +
148- $ "{ nameof ( IsAnonymousVpn ) } : { IsAnonymousVpn } , " +
149- $ "{ nameof ( IsHostingProvider ) } : { IsHostingProvider } , " +
150- $ "{ nameof ( IsPublicProxy ) } : { IsPublicProxy } , " +
151- $ "{ nameof ( IsResidentialProxy ) } : { IsResidentialProxy } , " +
152- $ "{ nameof ( IsTorExitNode ) } : { IsTorExitNode } , " +
153- #if NET6_0_OR_GREATER
154- $ "{ nameof ( NetworkLastSeen ) } : { NetworkLastSeen } , " +
155- #endif
156- $"{nameof(ProviderName)}: {ProviderName}" ;
157- }
95+ public string ? ProviderName { get ; init ; }
15896 }
15997}
0 commit comments