using System;
using System.Collections;
using System.Globalization;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
namespace System.Net
{
/// Contains HTTP proxy settings for the class.
// Token: 0x0200026D RID: 621
[Serializable]
public class WebProxy : ISerializable, IWebProxy
{
/// Initializes an empty instance of the class.
// Token: 0x060016EC RID: 5868 RVA: 0x0004D4D0 File Offset: 0x0004B6D0
public WebProxy()
: this(null, false, null, null)
{
}
/// Initializes a new instance of the class with the specified URI.
/// The URI of the proxy server.
///
/// is an invalid URI.
// Token: 0x060016ED RID: 5869 RVA: 0x0004D4DC File Offset: 0x0004B6DC
public WebProxy(string address)
: this(WebProxy.ToUri(address), false, null, null)
{
}
/// Initializes a new instance of the class from the specified instance.
/// A instance that contains the address of the proxy server.
// Token: 0x060016EE RID: 5870 RVA: 0x0004D4F0 File Offset: 0x0004B6F0
public WebProxy(global::System.Uri address)
: this(address, false, null, null)
{
}
/// Initializes a new instance of the class with the specified URI and bypass setting.
/// The URI of the proxy server.
/// true to bypass the proxy for local addresses; otherwise, false.
///
/// is an invalid URI.
// Token: 0x060016EF RID: 5871 RVA: 0x0004D4FC File Offset: 0x0004B6FC
public WebProxy(string address, bool bypassOnLocal)
: this(WebProxy.ToUri(address), bypassOnLocal, null, null)
{
}
/// Initializes a new instance of the class with the specified host and port number.
/// The name of the proxy host.
/// The port number on to use.
/// The URI formed by combining and is not a valid URI.
// Token: 0x060016F0 RID: 5872 RVA: 0x0004D510 File Offset: 0x0004B710
public WebProxy(string host, int port)
: this(new global::System.Uri(string.Concat(new object[] { "http://", host, ":", port })))
{
}
/// Initializes a new instance of the class with the instance and bypass setting.
/// A instance that contains the address of the proxy server.
/// true to bypass the proxy for local addresses; otherwise, false.
// Token: 0x060016F1 RID: 5873 RVA: 0x0004D548 File Offset: 0x0004B748
public WebProxy(global::System.Uri address, bool bypassOnLocal)
: this(address, bypassOnLocal, null, null)
{
}
/// Initializes a new instance of the class with the specified URI, bypass setting, and list of URIs to bypass.
/// The URI of the proxy server.
/// true to bypass the proxy for local addresses; otherwise, false.
/// An array of regular expression strings that contain the URIs of the servers to bypass.
///
/// is an invalid URI.
// Token: 0x060016F2 RID: 5874 RVA: 0x0004D554 File Offset: 0x0004B754
public WebProxy(string address, bool bypassOnLocal, string[] bypassList)
: this(WebProxy.ToUri(address), bypassOnLocal, bypassList, null)
{
}
/// Initializes a new instance of the class with the specified instance, bypass setting, and list of URIs to bypass.
/// A instance that contains the address of the proxy server.
/// true to bypass the proxy for local addresses; otherwise, false.
/// An array of regular expression strings that contains the URIs of the servers to bypass.
// Token: 0x060016F3 RID: 5875 RVA: 0x0004D568 File Offset: 0x0004B768
public WebProxy(global::System.Uri address, bool bypassOnLocal, string[] bypassList)
: this(address, bypassOnLocal, bypassList, null)
{
}
/// Initializes a new instance of the class with the specified URI, bypass setting, list of URIs to bypass, and credentials.
/// The URI of the proxy server.
/// true to bypass the proxy for local addresses; otherwise, false.
/// An array of regular expression strings that contains the URIs of the servers to bypass.
/// An instance to submit to the proxy server for authentication.
///
/// is an invalid URI.
// Token: 0x060016F4 RID: 5876 RVA: 0x0004D574 File Offset: 0x0004B774
public WebProxy(string address, bool bypassOnLocal, string[] bypassList, ICredentials credentials)
: this(WebProxy.ToUri(address), bypassOnLocal, bypassList, credentials)
{
}
/// Initializes a new instance of the class with the specified instance, bypass setting, list of URIs to bypass, and credentials.
/// A instance that contains the address of the proxy server.
/// true to bypass the proxy for local addresses; otherwise, false.
/// An array of regular expression strings that contains the URIs of the servers to bypass.
/// An instance to submit to the proxy server for authentication.
// Token: 0x060016F5 RID: 5877 RVA: 0x0004D588 File Offset: 0x0004B788
public WebProxy(global::System.Uri address, bool bypassOnLocal, string[] bypassList, ICredentials credentials)
{
this.address = address;
this.bypassOnLocal = bypassOnLocal;
if (bypassList != null)
{
this.bypassList = new ArrayList(bypassList);
}
this.credentials = credentials;
this.CheckBypassList();
}
/// Initializes an instance of the class using previously serialized content.
/// The serialization data.
/// The context for the serialized data.
// Token: 0x060016F6 RID: 5878 RVA: 0x0004D5CC File Offset: 0x0004B7CC
protected WebProxy(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
this.address = (global::System.Uri)serializationInfo.GetValue("_ProxyAddress", typeof(global::System.Uri));
this.bypassOnLocal = serializationInfo.GetBoolean("_BypassOnLocal");
this.bypassList = (ArrayList)serializationInfo.GetValue("_BypassList", typeof(ArrayList));
this.useDefaultCredentials = serializationInfo.GetBoolean("_UseDefaultCredentials");
this.credentials = null;
this.CheckBypassList();
}
/// Creates the serialization data and context that are used by the system to serialize a object.
/// The object to populate with data.
/// A structure that indicates the destination for this serialization.
// Token: 0x060016F7 RID: 5879 RVA: 0x0004D650 File Offset: 0x0004B850
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
this.GetObjectData(serializationInfo, streamingContext);
}
/// Gets or sets the address of the proxy server.
/// A instance that contains the address of the proxy server.
// Token: 0x1700074E RID: 1870
// (get) Token: 0x060016F8 RID: 5880 RVA: 0x0004D65C File Offset: 0x0004B85C
// (set) Token: 0x060016F9 RID: 5881 RVA: 0x0004D664 File Offset: 0x0004B864
public global::System.Uri Address
{
get
{
return this.address;
}
set
{
this.address = value;
}
}
/// Gets a list of addresses that do not use the proxy server.
/// An that contains a list of arrays that represents URIs that do not use the proxy server when accessed.
// Token: 0x1700074F RID: 1871
// (get) Token: 0x060016FA RID: 5882 RVA: 0x0004D670 File Offset: 0x0004B870
public ArrayList BypassArrayList
{
get
{
if (this.bypassList == null)
{
this.bypassList = new ArrayList();
}
return this.bypassList;
}
}
/// Gets or sets an array of addresses that do not use the proxy server.
/// An array that contains a list of regular expressions that describe URIs that do not use the proxy server when accessed.
// Token: 0x17000750 RID: 1872
// (get) Token: 0x060016FB RID: 5883 RVA: 0x0004D690 File Offset: 0x0004B890
// (set) Token: 0x060016FC RID: 5884 RVA: 0x0004D6AC File Offset: 0x0004B8AC
public string[] BypassList
{
get
{
return (string[])this.BypassArrayList.ToArray(typeof(string));
}
set
{
if (value == null)
{
throw new ArgumentNullException();
}
this.bypassList = new ArrayList(value);
this.CheckBypassList();
}
}
/// Gets or sets a value that indicates whether to bypass the proxy server for local addresses.
/// true to bypass the proxy server for local addresses; otherwise, false. The default value is false.
// Token: 0x17000751 RID: 1873
// (get) Token: 0x060016FD RID: 5885 RVA: 0x0004D6CC File Offset: 0x0004B8CC
// (set) Token: 0x060016FE RID: 5886 RVA: 0x0004D6D4 File Offset: 0x0004B8D4
public bool BypassProxyOnLocal
{
get
{
return this.bypassOnLocal;
}
set
{
this.bypassOnLocal = value;
}
}
/// Gets or sets the credentials to submit to the proxy server for authentication.
/// An instance that contains the credentials to submit to the proxy server for authentication.
/// You attempted to set this property when the property was set to true.
///
///
///
// Token: 0x17000752 RID: 1874
// (get) Token: 0x060016FF RID: 5887 RVA: 0x0004D6E0 File Offset: 0x0004B8E0
// (set) Token: 0x06001700 RID: 5888 RVA: 0x0004D6E8 File Offset: 0x0004B8E8
public ICredentials Credentials
{
get
{
return this.credentials;
}
set
{
this.credentials = value;
}
}
/// Gets or sets a value that controls whether the are sent with requests.
/// true if the default credentials are used; otherwise, false. The default value is false.
/// You attempted to set this property when the property contains credentials other than the default credentials. For more information, see the Remarks section.
///
///
///
// Token: 0x17000753 RID: 1875
// (get) Token: 0x06001701 RID: 5889 RVA: 0x0004D6F4 File Offset: 0x0004B8F4
// (set) Token: 0x06001702 RID: 5890 RVA: 0x0004D6FC File Offset: 0x0004B8FC
[global::System.MonoTODO("Does not affect Credentials, since CredentialCache.DefaultCredentials is not implemented.")]
public bool UseDefaultCredentials
{
get
{
return this.useDefaultCredentials;
}
set
{
this.useDefaultCredentials = value;
}
}
/// Reads the Internet Explorer nondynamic proxy settings.
/// A instance that contains the nondynamic proxy settings from Internet Explorer 5.5 and later.
///
///
///
///
///
///
///
// Token: 0x06001703 RID: 5891 RVA: 0x0004D708 File Offset: 0x0004B908
[Obsolete("This method has been deprecated", false)]
[global::System.MonoTODO("Can we get this info under windows from the system?")]
public static WebProxy GetDefaultProxy()
{
IWebProxy select = GlobalProxySelection.Select;
if (select is WebProxy)
{
return (WebProxy)select;
}
return new WebProxy();
}
/// Returns the proxied URI for a request.
/// The instance of the Internet resource, if the resource is on the bypass list; otherwise, the instance of the proxy.
/// The instance of the requested Internet resource.
// Token: 0x06001704 RID: 5892 RVA: 0x0004D734 File Offset: 0x0004B934
public global::System.Uri GetProxy(global::System.Uri destination)
{
if (this.IsBypassed(destination))
{
return destination;
}
return this.address;
}
/// Indicates whether to use the proxy server for the specified host.
/// true if the proxy server should not be used for ; otherwise, false.
/// The instance of the host to check for proxy use.
// Token: 0x06001705 RID: 5893 RVA: 0x0004D74C File Offset: 0x0004B94C
public bool IsBypassed(global::System.Uri host)
{
if (host == null)
{
throw new ArgumentNullException("host");
}
if (host.IsLoopback && this.bypassOnLocal)
{
return true;
}
if (this.address == null)
{
return true;
}
string host2 = host.Host;
if (this.bypassOnLocal && host2.IndexOf('.') == -1)
{
return true;
}
if (!this.bypassOnLocal)
{
if (string.Compare(host2, "localhost", true, CultureInfo.InvariantCulture) == 0)
{
return true;
}
if (string.Compare(host2, "loopback", true, CultureInfo.InvariantCulture) == 0)
{
return true;
}
IPAddress ipaddress = null;
if (IPAddress.TryParse(host2, out ipaddress) && IPAddress.IsLoopback(ipaddress))
{
return true;
}
}
if (this.bypassList == null || this.bypassList.Count == 0)
{
return false;
}
bool flag;
try
{
string text = host.Scheme + "://" + host.Authority;
int i;
for (i = 0; i < this.bypassList.Count; i++)
{
global::System.Text.RegularExpressions.Regex regex = new global::System.Text.RegularExpressions.Regex((string)this.bypassList[i], global::System.Text.RegularExpressions.RegexOptions.IgnoreCase | global::System.Text.RegularExpressions.RegexOptions.Singleline);
if (regex.IsMatch(text))
{
break;
}
}
if (i == this.bypassList.Count)
{
flag = false;
}
else
{
while (i < this.bypassList.Count)
{
new global::System.Text.RegularExpressions.Regex((string)this.bypassList[i]);
i++;
}
flag = true;
}
}
catch (ArgumentException)
{
flag = false;
}
return flag;
}
/// Populates a with the data that is needed to serialize the target object.
/// The to populate with data.
/// A that specifies the destination for this serialization.
// Token: 0x06001706 RID: 5894 RVA: 0x0004D914 File Offset: 0x0004BB14
protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
serializationInfo.AddValue("_BypassOnLocal", this.bypassOnLocal);
serializationInfo.AddValue("_ProxyAddress", this.address);
serializationInfo.AddValue("_BypassList", this.bypassList);
serializationInfo.AddValue("_UseDefaultCredentials", this.UseDefaultCredentials);
}
// Token: 0x06001707 RID: 5895 RVA: 0x0004D968 File Offset: 0x0004BB68
private void CheckBypassList()
{
if (this.bypassList == null)
{
return;
}
for (int i = 0; i < this.bypassList.Count; i++)
{
new global::System.Text.RegularExpressions.Regex((string)this.bypassList[i]);
}
}
// Token: 0x06001708 RID: 5896 RVA: 0x0004D9B4 File Offset: 0x0004BBB4
private static global::System.Uri ToUri(string address)
{
if (address == null)
{
return null;
}
if (address.IndexOf("://") == -1)
{
address = "http://" + address;
}
return new global::System.Uri(address);
}
// Token: 0x0400127E RID: 4734
private global::System.Uri address;
// Token: 0x0400127F RID: 4735
private bool bypassOnLocal;
// Token: 0x04001280 RID: 4736
private ArrayList bypassList;
// Token: 0x04001281 RID: 4737
private ICredentials credentials;
// Token: 0x04001282 RID: 4738
private bool useDefaultCredentials;
}
}