C# Class BF2Statistics.Redirector

Provides Methods to apply and remove Gamespy Redirects
Mostrar archivo Open project: BF2Statistics/ControlCenter Class Usage Examples

Public Properties

Property Type Description
Bf2StatsHost string
DnsCacheReport BF2Statistics.Gamespy.Redirector.GamespyDnsReport
GamespyHosts string[]
GamespyServerAddress System.Net.IPAddress
StatsServerAddress System.Net.IPAddress

Public Methods

Method Description
ApplyRedirectsAsync ( IProgress Progress ) : Task

Applies the specified IP address redirects for the chosen redirect method

Initialize ( ) : Task

The main entry point for the redirector

RebuildDNSCache ( CancellationToken CancelToken ) : void

Preforms the pings required to fill the dns cache. The reason we ping, is because once the HOSTS file is locked, any request made to a url (when the DNS cache is empty), will skip the hosts file, because it cant be read. If we ping first, then the DNS cache fills up with the IP addresses in the hosts file.

RemoveRedirects ( ) : void

Remove the redirects currently active

SetRedirectMode ( RedirectMode Mode ) : bool

Sets a new Redirect method. Using this method removes any previous redirects

VerifyDNSCache ( IProgress Progress = null ) : bool

Queries the DNS Cache for the Gamespy hosts, and verifies that the IP addresses in the DNS Cache match that of the desired redirect IP

Private Methods

Method Description
DnsFlushResolverCache ( ) : UInt32
DnsFlushResolverCacheEntry ( string hostName ) : int
RemoveRedirects ( HostsFile HostFile ) : void

Removes all gamespy related redirects in the specified hosts file container

Method Details

ApplyRedirectsAsync() public static method

Applies the specified IP address redirects for the chosen redirect method
public static ApplyRedirectsAsync ( IProgress Progress ) : Task
Progress IProgress
return Task

Initialize() public static method

The main entry point for the redirector
public static Initialize ( ) : Task
return Task

RebuildDNSCache() public static method

Preforms the pings required to fill the dns cache. The reason we ping, is because once the HOSTS file is locked, any request made to a url (when the DNS cache is empty), will skip the hosts file, because it cant be read. If we ping first, then the DNS cache fills up with the IP addresses in the hosts file.
public static RebuildDNSCache ( CancellationToken CancelToken ) : void
CancelToken System.Threading.CancellationToken
return void

RemoveRedirects() public static method

Remove the redirects currently active
public static RemoveRedirects ( ) : void
return void

SetRedirectMode() public static method

Sets a new Redirect method. Using this method removes any previous redirects
public static SetRedirectMode ( RedirectMode Mode ) : bool
Mode RedirectMode The new redirect mode
return bool

VerifyDNSCache() public static method

Queries the DNS Cache for the Gamespy hosts, and verifies that the IP addresses in the DNS Cache match that of the desired redirect IP
public static VerifyDNSCache ( IProgress Progress = null ) : bool
Progress IProgress
return bool

Property Details

Bf2StatsHost public_oe static_oe property

Returns the hostname for the battlefield 2 stats server
public static string Bf2StatsHost
return string

DnsCacheReport public_oe static_oe property

Gets the last DnsCacheReport object generated by the VerifyDNSCache method
public static GamespyDnsReport,BF2Statistics.Gamespy.Redirector DnsCacheReport
return BF2Statistics.Gamespy.Redirector.GamespyDnsReport

GamespyHosts public_oe static_oe property

Returns an array of all gamespy related service hostnames
public static string[] GamespyHosts
return string[]

GamespyServerAddress public_oe static_oe property

Gets or Sets the Gamespy Server address. If redirects are enabled, changes will not take effect until they are removed.
public static IPAddress,System.Net GamespyServerAddress
return System.Net.IPAddress

StatsServerAddress public_oe static_oe property

Gets or Sets the Stats Server address. If redirects are enabled, changes will not take effect until they are removed.
public static IPAddress,System.Net StatsServerAddress
return System.Net.IPAddress