1/*2 * ====================================================================3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 * ====================================================================20 *21 * This software consists of voluntary contributions made by many22 * individuals on behalf of the Apache Software Foundation. For more23 * information on the Apache Software Foundation, please see24 * <http://www.apache.org/>.25 *26 */2728package org.apache.http.conn.routing;
2930import java.net.InetAddress;
3132import org.apache.http.HttpHost;
3334/**35 * Read-only interface for route information.36 *37 * @since 4.038 */39publicinterfaceRouteInfo {
4041/**42 * The tunnelling type of a route.43 * Plain routes are established by connecting to the target or44 * the first proxy.45 * Tunnelled routes are established by connecting to the first proxy46 * and tunnelling through all proxies to the target.47 * Routes without a proxy cannot be tunnelled.48 */49public enum TunnelType { PLAIN, TUNNELLED }
5051/**52 * The layering type of a route.53 * Plain routes are established by connecting or tunnelling.54 * Layered routes are established by layering a protocol such as TLS/SSL55 * over an existing connection.56 * Protocols can only be layered over a tunnel to the target, or57 * or over a direct connection without proxies.58 * <p>59 * Layering a protocol60 * over a direct connection makes little sense, since the connection61 * could be established with the new protocol in the first place.62 * But we don't want to exclude that use case.63 * </p>64 */65public enum LayerType { PLAIN, LAYERED }
6667/**68 * Obtains the target host.69 *70 * @return the target host71 */72 HttpHost getTargetHost();
7374/**75 * Obtains the local address to connect from.76 *77 * @return the local address,78 * or {@code null}79 */80 InetAddress getLocalAddress();
8182/**83 * Obtains the number of hops in this route.84 * A direct route has one hop. A route through a proxy has two hops.85 * A route through a chain of <i>n</i> proxies has <i>n+1</i> hops.86 *87 * @return the number of hops in this route88 */89int getHopCount();
9091/**92 * Obtains the target of a hop in this route.93 * The target of the last hop is the {@link #getTargetHost target host},94 * the target of previous hops is the respective proxy in the chain.95 * For a route through exactly one proxy, target of hop 0 is the proxy96 * and target of hop 1 is the target host.97 *98 * @param hop index of the hop for which to get the target,99 * 0 for first100 *101 * @return the target of the given hop102 *103 * @throws IllegalArgumentException104 * if the argument is negative or not less than105 * {@link #getHopCount getHopCount()}106 */107 HttpHost getHopTarget(int hop);
108109/**110 * Obtains the first proxy host.111 *112 * @return the first proxy in the proxy chain, or113 * {@code null} if this route is direct114 */115 HttpHost getProxyHost();
116117/**118 * Obtains the tunnel type of this route.119 * If there is a proxy chain, only end-to-end tunnels are considered.120 *121 * @return the tunnelling type122 */123TunnelType getTunnelType();
124125/**126 * Checks whether this route is tunnelled through a proxy.127 * If there is a proxy chain, only end-to-end tunnels are considered.128 *129 * @return {@code true} if tunnelled end-to-end through at least130 * one proxy,131 * {@code false} otherwise132 */133boolean isTunnelled();
134135/**136 * Obtains the layering type of this route.137 * In the presence of proxies, only layering over an end-to-end tunnel138 * is considered.139 *140 * @return the layering type141 */142LayerType getLayerType();
143144/**145 * Checks whether this route includes a layered protocol.146 * In the presence of proxies, only layering over an end-to-end tunnel147 * is considered.148 *149 * @return {@code true} if layered,150 * {@code false} otherwise151 */152boolean isLayered();
153154/**155 * Checks whether this route is secure.156 *157 * @return {@code true} if secure,158 * {@code false} otherwise159 */160boolean isSecure();
161162 }