![]() |
BogaNet 1.4.0
|
Various helper functions for networking. More...
Static Public Member Functions | |
static ? IWebProxy | SetGlobalProxyToDefault () |
Sets the global proxy for all network requests to the default. | |
static IWebProxy | SetGlobalProxy (string user, string password, string url) |
Sets the global proxy for all network requests with the given credentials. | |
static bool | OpenURL (string? url) |
Opens the given URL with the file explorer or browser. | |
static bool | RemoteCertificateValidationCallback (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) |
HTTPS-certification callback, which overrides the checks for invalid certificates (like dev-certs). NOTE: do not use this in production since it breaks the SSL security! | |
static string | GetURLForFile (string path) |
Returns the URL of a given file. | |
static string | ValidateURL (string url, bool removeProtocol=false, bool removeWWW=true, bool removeSlash=true) |
Validates a given URL. | |
static bool | IsURL (string? url) |
Checks if the input is an URL. | |
static bool | IsIPv4 (string? ip) |
Checks if the input is an IPv4 address. | |
static bool | IsIPv6 (string? ip) |
Checks if the input is an IPv6 address. | |
static string | GetIP (string host) |
Returns the IP of a given host name. | |
static string | GetPublicIP (string checkUrl="https://checkip.amazonaws.com/") |
Returns the public IP of the Internet connection. | |
static async Task< string > | GetPublicIPAsync (string checkUrl="https://checkip.amazonaws.com/") |
Returns the public IP of the Internet connection asynchronously. | |
static List< NetworkAdapter > | GetNetworkAdapters (bool activeOnly=true) |
Returns a list of all available network interfaces. | |
static bool | CheckInternetAvailability () |
Checks the availability of the Internet (aka "Captive Portal Detection"). | |
static async Task< bool > | CheckInternetAvailabilityAsync () |
Checks the availability of the Internet (aka "Captive Portal Detection") asynchronously. | |
static long | Ping (string hostname) |
Pings a given host and returns the Roundtrip-Time. | |
static async Task< long > | PingAsync (string hostname) |
Pings a given host and returns the Roundtrip-Time asynchronously. | |
static string | ReadAllText (string url) |
Reads the text of a file from a given URL. | |
static async Task< string > | ReadAllTextAsync (string url) |
Reads the text of a file from a given URL asynchronously. | |
static string[] | ReadAllLines (string url) |
Reads all lines of text from a file from a given URL. | |
static async Task< string[]> | ReadAllLinesAsync (string url) |
Reads all lines of text from a file from a given URL asynchronously. | |
static byte[] | ReadAllBytes (string url) |
Reads the bytes of a file from a given URL. | |
static async Task< byte[]> | ReadAllBytesAsync (string url) |
Reads the bytes of a file from a given URL asynchronously. | |
Various helper functions for networking.
|
static |
Checks the availability of the Internet (aka "Captive Portal Detection").
|
static |
Checks the availability of the Internet (aka "Captive Portal Detection") asynchronously.
|
static |
Returns the IP of a given host name.
host | Host name |
Exception |
|
static |
Returns a list of all available network interfaces.
activeOnly | Search only for active network interfaces (optional, default: true) |
|
static |
Returns the public IP of the Internet connection.
checkUrl | External url to check the ip (optional, default: https://checkip.amazonaws.com/ |
|
static |
Returns the public IP of the Internet connection asynchronously.
checkUrl | External url to check the ip (optional, default: https://checkip.amazonaws.com/ |
|
static |
Returns the URL of a given file.
path | File path |
|
static |
Checks if the input is an IPv4 address.
ip | Input as possible IPv4 |
|
static |
Checks if the input is an IPv6 address.
ip | Input as possible IPv6 |
|
static |
Checks if the input is an URL.
url | Input as possible URL |
|
static |
Opens the given URL with the file explorer or browser.
url | URL to open |
Exception |
|
static |
Pings a given host and returns the Roundtrip-Time.
hostname | Host/IP to ping |
Exception |
|
static |
Pings a given host and returns the Roundtrip-Time asynchronously.
hostname | Host/IP to ping |
Exception |
|
static |
Reads the bytes of a file from a given URL.
url | URL to the file |
Exception |
|
static |
Reads the bytes of a file from a given URL asynchronously.
url | URL to the file |
Exception |
|
static |
Reads all lines of text from a file from a given URL.
url | URL to the file |
Exception |
|
static |
Reads all lines of text from a file from a given URL asynchronously.
url | URL to the file |
Exception |
|
static |
Reads the text of a file from a given URL.
url | URL to the file |
Exception |
|
static |
Reads the text of a file from a given URL asynchronously.
url | URL to the file |
Exception |
|
static |
HTTPS-certification callback, which overrides the checks for invalid certificates (like dev-certs). NOTE: do not use this in production since it breaks the SSL security!
sender | Sender of the callback |
certificate | Certificate to check |
chain | Chain to use |
sslPolicyErrors | SSL errors |
|
static |
Sets the global proxy for all network requests with the given credentials.
user | User for the proxy |
password | Password for the proxy |
url | Url of the proxy |
|
static |
Sets the global proxy for all network requests to the default.
|
static |
Validates a given URL.
url | URL to validate |
removeProtocol | Remove the protocol, e.g. http:// (optional, default: false) |
removeWWW | Remove www (optional, default: true) |
removeSlash | Remove slash at the end (optional, default: true) |
ArgumentNullException |