public static long uint32(InputStream stream) throws IOException { return uint32(stream, null); }
public static long uint32(InputStream in) throws IOException { return uint32(in, null); }
public static long varInt(InputStream stream, AccessCounter counter) throws IOException { int first = stream.read(); inc(counter); switch (first) { case 0xfd: return uint16(stream, counter); case 0xfe: return uint32(stream, counter); case 0xff: return int64(stream, counter); default: return first; } }
public static long varInt(InputStream in, AccessCounter counter) throws IOException { int first = in.read(); inc(counter); switch (first) { case 0xfd: return uint16(in, counter); case 0xfe: return uint32(in, counter); case 0xff: return int64(in, counter); default: return first; } }
length = (int) Decode.uint32(headerBuffer); if (length > MAX_PAYLOAD_SIZE) { throw new NodeException("Payload of " + length + " bytes received, no more than " +
public static NetworkMessage read(InputStream in) throws IOException { findMagic(in); String command = getCommand(in); int length = (int) Decode.uint32(in); byte[] checksum = Decode.bytes(in, 4); byte[] payloadBytes = Decode.bytes(in, length); if (testChecksum(checksum, payloadBytes)) { MessagePayload payload = getPayload(command, new ByteArrayInputStream(payloadBytes), length); if (payload != null) return new NetworkMessage(payload); else return null; } else { throw new IOException("Checksum failed for message '" + command + "'"); } }
public static NetworkMessage read(InputStream in) throws IOException { findMagic(in); String command = getCommand(in); int length = (int) Decode.uint32(in); if (length > 1600003) { throw new NodeException("Payload of " + length + " bytes received, no more than 1600003 was expected."); } byte[] checksum = Decode.bytes(in, 4); byte[] payloadBytes = Decode.bytes(in, length); if (testChecksum(checksum, payloadBytes)) { MessagePayload payload = getPayload(command, new ByteArrayInputStream(payloadBytes), length); if (payload != null) return new NetworkMessage(payload); else return null; } else { throw new IOException("Checksum failed for message '" + command + "'"); } }
public static V2Pubkey read(InputStream is, long stream) throws IOException { return new V2Pubkey.Builder() .stream(stream) .behaviorBitfield((int) Decode.uint32(is)) .publicSigningKey(Decode.bytes(is, 64)) .publicEncryptionKey(Decode.bytes(is, 64)) .build(); }
public static V2Pubkey read(InputStream is, long stream) throws IOException { return new V2Pubkey.Builder() .stream(stream) .behaviorBitfield((int) Decode.uint32(is)) .publicSigningKey(Decode.bytes(is, 64)) .publicEncryptionKey(Decode.bytes(is, 64)) .build(); }
public static ObjectMessage readObject(InputStream in, int length) throws IOException { AccessCounter counter = new AccessCounter(); byte nonce[] = Decode.bytes(in, 8, counter); long expiresTime = Decode.int64(in, counter); long objectType = Decode.uint32(in, counter); long version = Decode.varInt(in, counter); long stream = Decode.varInt(in, counter); byte[] data = Decode.bytes(in, length - counter.length()); ObjectPayload payload; try { ByteArrayInputStream dataStream = new ByteArrayInputStream(data); payload = Factory.getObjectPayload(objectType, version, stream, dataStream, data.length); } catch (IOException e) { LOG.trace("Could not parse object payload - using generic payload instead", e); payload = new GenericPayload(version, stream, data); } return new ObjectMessage.Builder() .nonce(nonce) .expiresTime(expiresTime) .objectType(objectType) .stream(stream) .payload(payload) .build(); }
public static ObjectMessage readObject(InputStream in, int length) throws IOException { AccessCounter counter = new AccessCounter(); byte nonce[] = Decode.bytes(in, 8, counter); long expiresTime = Decode.int64(in, counter); long objectType = Decode.uint32(in, counter); long version = Decode.varInt(in, counter); long stream = Decode.varInt(in, counter); byte[] data = Decode.bytes(in, length - counter.length()); ObjectPayload payload; try { ByteArrayInputStream dataStream = new ByteArrayInputStream(data); payload = Factory.getObjectPayload(objectType, version, stream, dataStream, data.length); } catch (Exception e) { LOG.trace("Could not parse object payload - using generic payload instead", e); payload = new GenericPayload(version, stream, data); } return new ObjectMessage.Builder() .nonce(nonce) .expiresTime(expiresTime) .objectType(objectType) .stream(stream) .payload(payload) .build(); }
private static NetworkAddress parseAddress(InputStream stream, boolean light) throws IOException { long time; long streamNumber; if (!light) { time = Decode.int64(stream); streamNumber = Decode.uint32(stream); // This isn't consistent, not sure if this is correct } else { time = 0; streamNumber = 0; } long services = Decode.int64(stream); byte[] ipv6 = Decode.bytes(stream, 16); int port = Decode.uint16(stream); return new NetworkAddress.Builder().time(time).stream(streamNumber).services(services).ipv6(ipv6).port(port).build(); }
private static NetworkAddress parseAddress(InputStream stream, boolean light) throws IOException { long time; long streamNumber; if (!light) { time = Decode.int64(stream); streamNumber = Decode.uint32(stream); // This isn't consistent, not sure if this is correct } else { time = 0; streamNumber = 0; } long services = Decode.int64(stream); byte[] ipv6 = Decode.bytes(stream, 16); int port = Decode.uint16(stream); return new NetworkAddress.Builder() .time(time) .stream(streamNumber) .services(services) .ipv6(ipv6) .port(port) .build(); }