Package jnode.protocol.binkp.types

Examples of jnode.protocol.binkp.types.BinkpFrame


        + " server connection");
  }

  protected void error(String text) {
    frames.clear();
    frames.addLast(new BinkpFrame(BinkpCommand.M_ERR, text));
    logger.l2("Local error: " + text);
    connectionState = STATE_ERROR;
  }
View Full Code Here


              receivingBytesLeft = 0;
            }
            recv_bytes += len;
            total_recv_bytes += len;
          } catch (IOException e) {
            frames.addLast(new BinkpFrame(BinkpCommand.M_SKIP,
                getString(receivingMessage)));
            receivingMessage = null;
            receivingBytesLeft = 0;
          }
        } else {
          logger.l4("Unknown data frame " + frame);
        }
        if (receivingBytesLeft == 0) {
          try {
            currentOS.close();
          } catch (IOException e) {
          }
          int ret = forwardToTossing(receivingMessage, currentFile,
              currentOS);
          frames.addLast(new BinkpFrame(
              (ret == 0) ? BinkpCommand.M_GOT
                  : BinkpCommand.M_SKIP,
              getString(receivingMessage)));
          logger.l3(String.format("Received file: %s (%d)",
              receivingMessage.getMessageName(),
View Full Code Here

  private void m_file(String arg) {
    receivingMessage = createMessage(arg, secure);
    long free_space = new File(FtnTools.getInbound()).getFreeSpace();
    if (receivingMessage.getMessageLength() > free_space) {
      frames.addLast(new BinkpFrame(BinkpCommand.M_SKIP,
          getString(receivingMessage)));
      receivingMessage = null;
      logger.l1("No enogth free space in inbound for receiving file");
    }
    if (!arg.split(" ")[3].equals("0")) {
      frames.addLast(new BinkpFrame(BinkpCommand.M_GET, getString(
          receivingMessage, 0)));
    } else {
      receivingBytesLeft = receivingMessage.getMessageLength();
      try {
        currentFile = File.createTempFile("temp", "jnode",
            staticTempDirectory);
        free_space = currentFile.getFreeSpace();
        if (receivingMessage.getMessageLength() > free_space) {
          logger.l1("No enogth free space in tmp for receiving file");
          currentFile.delete();
          throw new IOException();
        }
        currentOS = new FileOutputStream(currentFile);
      } catch (IOException e) {
        currentFile = null;
        if (receivingMessage.getMessageLength() < staticMemMaxSize) {
          currentOS = new ByteArrayOutputStream(
              (int) receivingMessage.getMessageLength());
        } else {
          frames.addLast(new BinkpFrame(BinkpCommand.M_SKIP,
              getString(receivingMessage)));
          receivingMessage = null;
          receivingBytesLeft = 0;
        }
      }
View Full Code Here

    } else {
      text = "(U) Unsecure connection with " + foreignAddress.get(0);
    }
    if (valid) {
      logger.l3(text);
      frames.addLast(new BinkpFrame(BinkpCommand.M_OK, text));
      connectionState = STATE_TRANSFER;
    } else {
      error("Invalid password");
      connectionState = STATE_ERROR;
    }
View Full Code Here

      } else {
        busy("Already connected with " + addr.toString());
      }
    }
    if (clientConnection) {
      frames.addLast(new BinkpFrame(BinkpCommand.M_PWD, getAuthPassword(
          foreignLink, secure, cramAlgo, cramText)));
    } else {
      sendAddrs();
    }
    connectionState = STATE_AUTH;
View Full Code Here

  }

  protected void busy(String string) {
    frames.clear();
    frames.addLast(new BinkpFrame(BinkpCommand.M_BSY, string));
    connectionState = STATE_END;
    logger.l3("Local busy: " + string);
  }
View Full Code Here

      } else {
        sb.append(" ");
      }
      sb.append(a.toString() + "@" + staticNetworkName);
    }
    frames.addLast(new BinkpFrame(BinkpCommand.M_ADR, sb.toString()));
  }
View Full Code Here

    }
    if (flag_leob) {
      return;
    }
    if (messages.size() > 0) {
      BinkpFrame frame = readFrame();
      if (frame != null) {
        frames.addLast(frame);
      }
      return;
    }
    for (FtnAddress a : foreignAddress) {
      messages.addAll(TosserQueue.getInstanse().getMessages(a));
    }
    if (messages.isEmpty()) {
      if (!flag_leob) {
        flag_leob = true;
        frames.addLast(new BinkpFrame(BinkpCommand.M_EOB));
        checkEOB();
      }
    } else {
      messages_index = 0;
      startNextFile();
View Full Code Here

      finish("From greet()");
    }
    addTimeout();
    SystemInfo info = MainHandler.getCurrentInstance().getInfo();
    ourAddress.addAll(info.getAddressList());
    frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, "SYS "
        + info.getStationName()));
    frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, "ZYZ "
        + info.getSysop()));
    frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, "LOC "
        + info.getLocation()));
    frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, "NDL "
        + info.getNDL()));
    frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, "VER "
        + MainHandler.getVersion() + " binkp/1.1"));
    frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, "TIME "
        + format.format(new Date())));

    connectionState = STATE_ADDR;
    if (clientConnection) {
      sendAddrs();
    } else {
      MessageDigest md;
      try {
        md = MessageDigest.getInstance("MD5");
        md.update(String.format("%d%d", System.currentTimeMillis(),
            System.nanoTime()).getBytes());
        byte[] digest = md.digest();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 16; i++) {
          builder.append(String.format("%02x", digest[i]));
        }
        cramText = builder.toString();
        cramAlgo = "MD5";
        frames.addLast(new BinkpFrame(BinkpCommand.M_NUL, String
            .format("OPT CRAM-MD5-%s", cramText)));

      } catch (NoSuchAlgorithmException e) {
        cramText = null;
      }
View Full Code Here

        sent_bytes += n;
        if (n > 0) {
          sent_bytes += n;
          total_sent_bytes += n;
          addTimeout();
          return new BinkpFrame(buf, n);
        } else {
          currentInputStream.close();
          currentInputStream = null;
          logger.l5("received EOF on current IO");
          messages_index++;
View Full Code Here

TOP

Related Classes of jnode.protocol.binkp.types.BinkpFrame

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.