Exemplo n.º 1
0
  void stopRemoteTunnels(MultiplexedConnection agent, Collection<Tunnel> tunnels)
      throws CoreException {

    CoreException e = null;

    for (Tunnel tunnel : tunnels) {
      try {
        RemoteTunnel rt =
            RemoteTunnelManagerFactory.getInstance().getRemoteTunnel(tunnel.getResourceId());
        if (rt != null) {
          rt.stopListener();
        } else {
          throw new Exception("No active with ID for " + tunnel.getResourceId());
        }
      } catch (Exception ex) {
        throw new TunnelException(TunnelException.INTERNAL_ERROR, ex);
      }
    }
    if (e != null) {
      throw e;
    }
  }
Exemplo n.º 2
0
  Request buildLocalTunnel(Tunnel tunnel, LaunchSession launchSession) throws IOException {
    // Process destination host and port for replacement variables
    VariableReplacement r = new VariableReplacement();
    r.setLaunchSession(launchSession);
    String destHost = r.replace(tunnel.getDestination().getHost());

    ByteArrayWriter msg = new ByteArrayWriter();
    msg.writeString(launchSession == null ? "" : launchSession.getId());
    msg.writeInt(tunnel.getResourceId());
    msg.writeString(tunnel.getResourceName());
    msg.writeInt(tunnel.getType());
    msg.writeString(tunnel.getTransport());
    msg.writeString(tunnel.getSourceInterface());
    msg.writeInt(tunnel.getSourcePort());
    msg.writeInt(tunnel.getDestination().getPort());
    msg.writeString(destHost);
    Request req = new Request(START_LOCAL_TUNNEL, msg.toByteArray());
    return req;
  }
Exemplo n.º 3
0
  void stopLocalTunnels(MultiplexedConnection agent, Collection<Tunnel> tunnels)
      throws CoreException {

    CoreException e = null;

    for (Tunnel tunnel : tunnels) {
      try {
        ByteArrayWriter msg = new ByteArrayWriter();
        msg.writeInt(tunnel.getResourceId());
        if (!agent.sendRequest(new Request(STOP_LOCAL_TUNNEL, msg.toByteArray()), false)
            && e == null) {
          e =
              new TunnelException(
                  TunnelException.AGENT_REFUSED_LOCAL_TUNNEL_STOP, (Throwable) null);
        }
      } catch (IOException ex) {
        throw new TunnelException(TunnelException.INTERNAL_ERROR, ex);
      }
    }
    if (e != null) {
      throw e;
    }
  }