protected boolean execStreamConnect(Properties props) {
    try {
      if (props == null) {
        notifyStreamResult(true, "I2P_ERROR", "No parameters specified in STREAM CONNECT message");
        _log.debug("No parameters specified in STREAM CONNECT message");
        return false;
      }
      boolean verbose = props.getProperty("SILENT", "false").equals("false");

      String dest = props.getProperty("DESTINATION");
      if (dest == null) {
        notifyStreamResult(verbose, "I2P_ERROR", "Destination not specified in RAW SEND message");
        _log.debug("Destination not specified in RAW SEND message");
        return false;
      }
      props.remove("DESTINATION");

      try {
        streamSession.connect(this, dest, props);
        return true;
      } catch (DataFormatException e) {
        _log.debug("Invalid destination in STREAM CONNECT message");
        notifyStreamResult(verbose, "INVALID_KEY", null);
      } catch (ConnectException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamResult(verbose, "CONNECTION_REFUSED", null);
      } catch (NoRouteToHostException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamResult(verbose, "CANT_REACH_PEER", null);
      } catch (InterruptedIOException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamResult(verbose, "TIMEOUT", null);
      } catch (I2PException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamResult(verbose, "I2P_ERROR", e.getMessage());
      }
    } catch (IOException e) {
    }
    return false;
  }
Exemple #2
0
  protected boolean execStreamConnect(Properties props) {
    if (props == null) {
      _log.debug("No parameters specified in STREAM CONNECT message");
      return false;
    }

    int id;
    {
      String strid = props.getProperty("ID");
      if (strid == null) {
        _log.debug("ID not specified in STREAM SEND message");
        return false;
      }
      try {
        id = Integer.parseInt(strid);
      } catch (NumberFormatException e) {
        _log.debug("Invalid STREAM CONNECT ID specified: " + strid);
        return false;
      }
      if (id < 1) {
        _log.debug("Invalid STREAM CONNECT ID specified: " + strid);
        return false;
      }
      props.remove("ID");
    }

    String dest = props.getProperty("DESTINATION");
    if (dest == null) {
      _log.debug("Destination not specified in RAW SEND message");
      return false;
    }
    props.remove("DESTINATION");

    try {
      try {
        if (!getStreamSession().connect(id, dest, props)) {
          _log.debug("STREAM connection failed");
          return false;
        }
      } catch (DataFormatException e) {
        _log.debug("Invalid destination in STREAM CONNECT message");
        notifyStreamOutgoingConnection(id, "INVALID_KEY", null);
      } catch (SAMInvalidDirectionException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamOutgoingConnection(id, "INVALID_DIRECTION", null);
      } catch (ConnectException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamOutgoingConnection(id, "CONNECTION_REFUSED", null);
      } catch (NoRouteToHostException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamOutgoingConnection(id, "CANT_REACH_PEER", null);
      } catch (InterruptedIOException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamOutgoingConnection(id, "TIMEOUT", null);
      } catch (I2PException e) {
        _log.debug("STREAM CONNECT failed: " + e.getMessage());
        notifyStreamOutgoingConnection(id, "I2P_ERROR", null);
      }
    } catch (IOException e) {
      return false;
    }

    return true;
  }