Exemplo n.º 1
0
 @Override
 public Result process(
     ConnectionService connectionService, String request, boolean wantReply, Buffer buffer)
     throws Exception {
   if (request.startsWith("no-more-sessions@")) {
     connectionService.setAllowMoreSessions(false);
     return Result.ReplyFailure;
   }
   return Result.Unsupported;
 }
Exemplo n.º 2
0
  @Override
  public Result process(
      ConnectionService connectionService, String request, boolean wantReply, Buffer buffer)
      throws Exception {
    if (!REQUEST.equals(request)) {
      return super.process(connectionService, request, wantReply, buffer);
    }

    String address = buffer.getString();
    int port = buffer.getInt();
    SshdSocketAddress socketAddress = new SshdSocketAddress(address, port);
    TcpipForwarder forwarder =
        Objects.requireNonNull(connectionService.getTcpipForwarder(), "No TCP/IP forwarder");
    SshdSocketAddress bound = forwarder.localPortForwardingRequested(socketAddress);
    if (log.isDebugEnabled()) {
      log.debug(
          "process({})[{}][want-reply-{}] {} => {}",
          connectionService,
          request,
          wantReply,
          socketAddress,
          bound);
    }

    if (bound == null) {
      return Result.ReplyFailure;
    }

    port = bound.getPort();
    if (wantReply) {
      Session session = connectionService.getSession();
      buffer = session.createBuffer(SshConstants.SSH_MSG_REQUEST_SUCCESS, Integer.BYTES);
      buffer.putInt(port);
      session.writePacket(buffer);
    }

    return Result.Replied;
  }
Exemplo n.º 3
0
 public String initialize() throws IOException {
   try {
     if (agentId == null) {
       agentServer =
           service.getSession().getFactoryManager().getAgentFactory().createServer(service);
       agentId = agentServer.getId();
     }
     return agentId;
   } catch (IOException e) {
     throw e;
   } catch (Exception e) {
     throw new SshException(e);
   }
 }
 public DefaultTcpipForwarder(ConnectionService service) {
   this.service = ValidateUtils.checkNotNull(service, "No connection service");
   this.session = ValidateUtils.checkNotNull(service.getSession(), "No session");
 }