Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QNetworkProxy class provides a network layer proxy. More...
Public Types | |
enum | Capability { CachingCapability = 8, HostNameLookupCapability = 16, ListeningCapability = 2, TunnelingCapability = 1, UdpTunnelingCapability = 4 } |
More... | |
enum | ProxyType { DefaultProxy = 0, FtpCachingProxy = 5, HttpCachingProxy = 4, HttpProxy = 3, NoProxy = 2, Socks5Proxy = 1 } |
More... | |
Public Member Functions | |
override bool | Equals (object o) |
override int | GetHashCode () |
QNetworkProxy () | |
| |
QNetworkProxy (QNetworkProxy other) | |
| |
QNetworkProxy (QNetworkProxy.ProxyType type, string hostName="", ushort port=0, string user="", string password="") | |
| |
virtual void | CreateProxy () |
new bool | IsCachingProxy () |
| |
new bool | IsTransparentProxy () |
| |
new void | Dispose () |
Static Public Member Functions | |
static bool | operator!= (QNetworkProxy arg1, QNetworkProxy arg2) |
| |
static bool | operator== (QNetworkProxy arg1, QNetworkProxy arg2) |
| |
Protected Member Functions | |
QNetworkProxy (System.Type dummy) | |
Protected Attributes | |
SmokeInvocation | interceptor |
Properties | |
static QNetworkProxy | ApplicationProxy [get, set] |
| |
new QNetworkProxy.Capability | Capabilities [get, set] |
| |
new string | HostName [get, set] |
| |
new string | Password [get, set] |
| |
new ushort | Port [get, set] |
| |
new QNetworkProxy.ProxyType | Type [get, set] |
| |
new string | User [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
The QNetworkProxy class provides a network layer proxy.
QNetworkProxy provides the method for configuring network layer proxy support to the Qt network classes. The currently supported classes are QAbstractSocket, QTcpSocket, QUdpSocket, QTcpServer, QNetworkAccessManager and QFtp. The proxy support is designed to be as transparent as possible. This means that existing network-enabled applications that you have written should automatically support network proxy using the following code.
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName("proxy.example.com");
proxy.setPort(1080);
proxy.setUser("username");
proxy.setPassword("password");
QNetworkProxy::setApplicationProxy(proxy);
An alternative to setting an application wide proxy is to specify the proxy for individual sockets using QAbstractSocket::setProxy() and QTcpServer::setProxy(). In this way, it is possible to disable the use of a proxy for specific sockets using the following code:
serverSocket->setProxy(QNetworkProxy::NoProxy);
Network proxy is not used if the address used in connectToHost(), bind() or listen() is equivalent to QHostAddress::LocalHost or QHostAddress::LocalHostIPv6.
Each type of proxy support has certain restrictions associated with it. You should read the ProxyType documentation carefully before selecting a proxy type to use.
Note: Changes made to currently connected sockets do not take effect. If you need to change a connected socket, you should reconnect it.
SOCKS5
The SOCKS5 support in Qt 4 is based on RFC 1928 and RFC 1929. The supported authentication methods are no authentication and username/password authentication. Both IPv4 and IPv6 are supported. Domain names are resolved through the SOCKS5 server if the QNetworkProxy::HostNameLookupCapability is enabled, otherwise they are resolved locally and the IP address is sent to the server. There are several things to remember when using SOCKS5 with QUdpSocket and QTcpServer:
With QUdpSocket, a call to bind() may fail with a timeout error. If a port number other than 0 is passed to bind(), it is not guaranteed that it is the specified port that will be used. Use localPort() and localAddress() to get the actual address and port number in use. Because proxied UDP goes through two UDP connections, it is more likely that packets will be dropped.
With QTcpServer a call to listen() may fail with a timeout error. If a port number other than 0 is passed to listen(), then it is not guaranteed that it is the specified port that will be used. Use serverPort() and serverAddress() to get the actual address and port used to listen for connections. SOCKS5 only supports one accepted connection per call to listen(), and each call is likely to result in a different serverPort() being used.
See also QAbstractSocket and QTcpServer.
These flags indicate the capabilities that a given proxy server supports.
QNetworkProxy sets different capabilities by default when the object is created (see QNetworkProxy::ProxyType for a list of the defaults). However, it is possible to change the capabitilies after the object has been created with setCapabilities().
The capabilities that QNetworkProxy supports are:
This enum was introduced or modified in Qt 4.5.
This enum describes the types of network proxying provided in Qt.
There are two types of proxies that Qt understands: transparent proxies and caching proxies. The first group consists of proxies that can handle any arbitrary data transfer, while the second can only handle specific requests. The caching proxies only make sense for the specific classes where they can be used.
The table below lists different proxy types and their capabilities. Since each proxy type has different capabilities, it is important to understand them before choosing a proxy type.
Proxy typeDescriptionDefault capabilities
SOCKS 5 Generic proxy for any kind of connection. Supports TCP, UDP, binding to a port (incoming connections) and authentication. TunnelingCapability, ListeningCapability, UdpTunnelingCapability, HostNameLookupCapability
HTTP Implemented using the "CONNECT" command, supports only outgoing TCP connections; supports authentication. TunnelingCapability, CachingCapability, HostNameLookupCapability
Caching-only HTTP Implemented using normal HTTP commands, it is useful only in the context of HTTP requests (see QNetworkAccessManager) CachingCapability, HostNameLookupCapability
Caching FTP Implemented using an FTP proxy, it is useful only in the context of FTP requests (see QFtp, QNetworkAccessManager) CachingCapability, HostNameLookupCapability
Also note that you shouldn't set the application default proxy (setApplicationProxy()) to a proxy that doesn't have the TunnelingCapability capability. If you do, QTcpSocket will not know how to open connections.
See also setType(), type(), capabilities(), and setCapabilities().
|
protected |
QtNetwork.QNetworkProxy.QNetworkProxy | ( | ) |
Constructs a QNetworkProxy with DefaultProxy type; the proxy type is determined by applicationProxy(), which defaults to NoProxy.
See also setType() and setApplicationProxy().
QtNetwork.QNetworkProxy.QNetworkProxy | ( | QNetworkProxy | other | ) |
Constructs a copy of other.
QtNetwork.QNetworkProxy.QNetworkProxy | ( | QNetworkProxy.ProxyType | type, |
string | hostName = "" , |
||
ushort | port = 0 , |
||
string | user = "" , |
||
string | password = "" |
||
) |
Constructs a QNetworkProxy with DefaultProxy type; the proxy type is determined by applicationProxy(), which defaults to NoProxy.
See also setType() and setApplicationProxy().
|
virtual |
new void QtNetwork.QNetworkProxy.Dispose | ( | ) |
override bool QtNetwork.QNetworkProxy.Equals | ( | object | o | ) |
override int QtNetwork.QNetworkProxy.GetHashCode | ( | ) |
new bool QtNetwork.QNetworkProxy.IsCachingProxy | ( | ) |
Returns true if this proxy supports the QNetworkProxy::CachingCapability capability.
In Qt 4.4, the capability was tied to the proxy type, but since Qt 4.5 it is possible to remove the capability of caching from a proxy by calling setCapabilities().
This function was introduced in Qt 4.4.
See also capabilities(), type(), and isTransparentProxy().
new bool QtNetwork.QNetworkProxy.IsTransparentProxy | ( | ) |
Returns true if this proxy supports transparent tunneling of TCP connections. This matches the QNetworkProxy::TunnelingCapability capability.
In Qt 4.4, the capability was tied to the proxy type, but since Qt 4.5 it is possible to remove the capability of caching from a proxy by calling setCapabilities().
This function was introduced in Qt 4.4.
See also capabilities(), type(), and isCachingProxy().
|
static |
Compares the value of this network proxy to other and returns true if they differ.
This function was introduced in Qt 4.4.
|
static |
Compares the value of this network proxy to other and returns true if they are equal (same proxy type, server as well as username and password)
This function was introduced in Qt 4.4.
|
protected |
|
staticgetset |
Returns the application level network proxying.
If a QAbstractSocket or QTcpSocket has the QNetworkProxy::DefaultProxy type, then the QNetworkProxy returned by this function is used.
Sets the application level network proxying to be networkProxy.
If a QAbstractSocket or QTcpSocket has the QNetworkProxy::DefaultProxy type, then the QNetworkProxy set with this function is used. If you want more flexibility in determining which the proxy, use the QNetworkProxyFactory class.
Setting a default proxy value with this function will override the application proxy factory set with QNetworkProxyFactory::setApplicationProxyFactory.
|
getset |
Returns the capabilities of this proxy server.
This function was introduced in Qt 4.5.
Sets the capabilities of this proxy to capabilities.
This function was introduced in Qt 4.5.
|
getset |
Returns the host name of the proxy host.
Sets the host name of the proxy host to be hostName.
|
getset |
Returns the password used for authentication.
Sets the password for proxy authentication to be password.
|
getset |
Returns the port of the proxy host.
Sets the port of the proxy host to be port.
|
getset |
|
getset |
Returns the proxy type for this instance.
Sets the proxy type for this instance to be type.
Note that changing the type of a proxy does not change the set of capabilities this QNetworkProxy object holds if any capabilities have been set with setCapabilities().
|
getset |
Returns the user name used for authentication.
Sets the user name for proxy authentication to be user.