本文整理汇总了Java中java.net.Proxy.Type.DIRECT属性的典型用法代码示例。如果您正苦于以下问题:Java Type.DIRECT属性的具体用法?Java Type.DIRECT怎么用?Java Type.DIRECT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.net.Proxy.Type
的用法示例。
在下文中一共展示了Type.DIRECT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldPipeline
private boolean shouldPipeline()
{
if (!this.pipeline)
{
return false;
}
else
{
Proxy proxy = Minecraft.getMinecraft().getProxy();
return proxy.type() != Type.DIRECT && proxy.type() != Type.SOCKS ? false : this.imageUrl.startsWith("http://");
}
}
示例2: connectFailed
public void connectFailed(Route failedRoute, IOException failure) {
if (!(failedRoute.getProxy().type() == Type.DIRECT || this.address.getProxySelector() ==
null)) {
this.address.getProxySelector().connectFailed(this.address.url().uri(), failedRoute
.getProxy().address(), failure);
}
this.routeDatabase.failed(failedRoute);
}
示例3: resetNextInetSocketAddress
private void resetNextInetSocketAddress(Proxy proxy) throws IOException {
String socketHost;
int socketPort;
this.inetSocketAddresses = new ArrayList();
if (proxy.type() == Type.DIRECT || proxy.type() == Type.SOCKS) {
socketHost = this.address.getUriHost();
socketPort = this.address.getUriPort();
} else {
SocketAddress proxyAddress = proxy.address();
if (proxyAddress instanceof InetSocketAddress) {
InetSocketAddress proxySocketAddress = (InetSocketAddress) proxyAddress;
socketHost = getHostString(proxySocketAddress);
socketPort = proxySocketAddress.getPort();
} else {
throw new IllegalArgumentException("Proxy.address() is not an InetSocketAddress: " +
"" + proxyAddress.getClass());
}
}
if (socketPort < 1 || socketPort > 65535) {
throw new SocketException("No route to " + socketHost + ":" + socketPort + "; port is" +
" out of range");
}
if (proxy.type() == Type.SOCKS) {
this.inetSocketAddresses.add(InetSocketAddress.createUnresolved(socketHost,
socketPort));
} else {
List<InetAddress> addresses = this.address.getDns().lookup(socketHost);
int size = addresses.size();
for (int i = 0; i < size; i++) {
this.inetSocketAddresses.add(new InetSocketAddress((InetAddress) addresses.get(i)
, socketPort));
}
}
this.nextInetSocketAddressIndex = 0;
}
示例4: usingProxy
public final boolean usingProxy() {
Proxy proxy;
if (this.route != null) {
proxy = this.route.getProxy();
} else {
proxy = this.client.getProxy();
}
return (proxy == null || proxy.type() == Type.DIRECT) ? false : true;
}
示例5: toType
Type toType(){
switch (this){
case SOCKS: return Type.SOCKS;
case HTTP: return Type.HTTP;
}
return Type.DIRECT;
}
示例6: getConnectToInetAddress
private InetAddress getConnectToInetAddress(Proxy proxy, HttpUrl url) throws IOException {
if (proxy == null || proxy.type() == Type.DIRECT) {
return InetAddress.getByName(url.host());
}
return ((InetSocketAddress) proxy.address()).getAddress();
}
示例7: connect
public void connect(int connectTimeout, int readTimeout, int writeTimeout,
List<ConnectionSpec> connectionSpecs, boolean connectionRetryEnabled)
throws RouteException {
if (this.protocol != null) {
throw new IllegalStateException("already connected");
}
RouteException routeException = null;
ConnectionSpecSelector connectionSpecSelector = new ConnectionSpecSelector(connectionSpecs);
Proxy proxy = this.route.getProxy();
Address address = this.route.getAddress();
if (this.route.getAddress().getSslSocketFactory() != null || connectionSpecs.contains
(ConnectionSpec.CLEARTEXT)) {
while (this.protocol == null) {
try {
Socket createSocket = (proxy.type() == Type.DIRECT || proxy.type() == Type
.HTTP) ? address.getSocketFactory().createSocket() : new Socket(proxy);
this.rawSocket = createSocket;
connectSocket(connectTimeout, readTimeout, writeTimeout,
connectionSpecSelector);
} catch (IOException e) {
Util.closeQuietly(this.socket);
Util.closeQuietly(this.rawSocket);
this.socket = null;
this.rawSocket = null;
this.source = null;
this.sink = null;
this.handshake = null;
this.protocol = null;
if (routeException == null) {
routeException = new RouteException(e);
} else {
routeException.addConnectException(e);
}
if (!connectionRetryEnabled || !connectionSpecSelector.connectionFailed(e)) {
throw routeException;
}
}
}
return;
}
throw new RouteException(new UnknownServiceException("CLEARTEXT communication not " +
"supported: " + connectionSpecs));
}