and again some more ;)
This commit is contained in:
@ -39,11 +39,13 @@ public class AbuseReason extends DataStructureImpl {
|
|||||||
public void setReason(String reason) {
|
public void setReason(String reason) {
|
||||||
_reason = reason;
|
_reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
||||||
_reason = DataHelper.readString(in);
|
_reason = DataHelper.readString(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
if (_reason == null) throw new DataFormatException("Invalid abuse reason");
|
if (_reason == null) throw new DataFormatException("Invalid abuse reason");
|
||||||
DataHelper.writeString(out, _reason);
|
DataHelper.writeString(out, _reason);
|
||||||
|
@ -41,10 +41,12 @@ public class AbuseSeverity extends DataStructureImpl {
|
|||||||
_severityId = id;
|
_severityId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
||||||
_severityId = (int) DataHelper.readLong(in, 1);
|
_severityId = (int) DataHelper.readLong(in, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
if (_severityId < 0) throw new DataFormatException("Invalid abuse severity: " + _severityId);
|
if (_severityId < 0) throw new DataFormatException("Invalid abuse severity: " + _severityId);
|
||||||
DataHelper.writeLong(out, 1, _severityId);
|
DataHelper.writeLong(out, 1, _severityId);
|
||||||
|
@ -73,6 +73,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
_leaseSet = leaseSet;
|
_leaseSet = leaseSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = new SessionId();
|
_sessionId = new SessionId();
|
||||||
@ -88,6 +89,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if ((_sessionId == null) || (_signingPrivateKey == null) || (_privateKey == null) || (_leaseSet == null))
|
if ((_sessionId == null) || (_signingPrivateKey == null) || (_privateKey == null) || (_leaseSet == null))
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
@ -107,6 +109,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ public class CreateSessionMessage extends I2CPMessageImpl {
|
|||||||
_sessionConfig = config;
|
_sessionConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
SessionConfig config = new SessionConfig();
|
SessionConfig config = new SessionConfig();
|
||||||
try {
|
try {
|
||||||
@ -54,6 +55,7 @@ public class CreateSessionMessage extends I2CPMessageImpl {
|
|||||||
setSessionConfig(config);
|
setSessionConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if (_sessionConfig == null)
|
if (_sessionConfig == null)
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
@ -66,6 +68,7 @@ public class CreateSessionMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public class DestroySessionMessage extends I2CPMessageImpl {
|
|||||||
_sessionId = id;
|
_sessionId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
SessionId id = new SessionId();
|
SessionId id = new SessionId();
|
||||||
try {
|
try {
|
||||||
@ -50,6 +51,7 @@ public class DestroySessionMessage extends I2CPMessageImpl {
|
|||||||
setSessionId(id);
|
setSessionId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if (_sessionId == null)
|
if (_sessionId == null)
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
|
@ -40,6 +40,7 @@ public class DisconnectMessage extends I2CPMessageImpl {
|
|||||||
_reason = reason;
|
_reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_reason = DataHelper.readString(in);
|
_reason = DataHelper.readString(in);
|
||||||
@ -48,6 +49,7 @@ public class DisconnectMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
|
||||||
try {
|
try {
|
||||||
@ -58,6 +60,7 @@ public class DisconnectMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,18 @@ public class GetDateMessage extends I2CPMessageImpl {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
byte rv[] = new byte[0];
|
byte rv[] = new byte[0];
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void readMessage(InputStream in) throws I2CPMessageException, IOException {
|
public void readMessage(InputStream in) throws I2CPMessageException, IOException {
|
||||||
int length = 0;
|
int length = 0;
|
||||||
try {
|
try {
|
||||||
@ -57,6 +58,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM
|
|||||||
* @param length number of bytes in the message payload
|
* @param length number of bytes in the message payload
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException {
|
public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException {
|
||||||
if (type != getType())
|
if (type != getType())
|
||||||
throw new I2CPMessageException("Invalid message type (found: " + type + " supported: " + getType()
|
throw new I2CPMessageException("Invalid message type (found: " + type + " supported: " + getType()
|
||||||
@ -103,6 +105,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
|
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
|
||||||
byte[] data = doWriteMessage();
|
byte[] data = doWriteMessage();
|
||||||
try {
|
try {
|
||||||
@ -114,6 +117,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM
|
|||||||
out.write(data);
|
out.write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
||||||
try {
|
try {
|
||||||
readMessage(in);
|
readMessage(in);
|
||||||
@ -122,6 +126,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
try {
|
try {
|
||||||
writeMessage(out);
|
writeMessage(out);
|
||||||
|
@ -144,6 +144,7 @@ public class I2CPMessageReader {
|
|||||||
_stream = null;
|
_stream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (_stayAlive) {
|
while (_stayAlive) {
|
||||||
while (_doRun) {
|
while (_doRun) {
|
||||||
|
@ -43,10 +43,12 @@ public class MessageId extends DataStructureImpl {
|
|||||||
_messageId = id;
|
_messageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
||||||
_messageId = DataHelper.readLong(in, 4);
|
_messageId = DataHelper.readLong(in, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
if (_messageId < 0) throw new DataFormatException("Invalid message ID: " + _messageId);
|
if (_messageId < 0) throw new DataFormatException("Invalid message ID: " + _messageId);
|
||||||
DataHelper.writeLong(out, 4, _messageId);
|
DataHelper.writeLong(out, 4, _messageId);
|
||||||
|
@ -61,6 +61,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl {
|
|||||||
_payload = payload;
|
_payload = payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = DataHelper.readLong(in, 2);
|
_sessionId = DataHelper.readLong(in, 2);
|
||||||
@ -72,6 +73,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
throw new RuntimeException("go away, we dont want any");
|
throw new RuntimeException("go away, we dont want any");
|
||||||
}
|
}
|
||||||
@ -104,6 +106,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ public class MessageStatusMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = DataHelper.readLong(in, 2);
|
_sessionId = DataHelper.readLong(in, 2);
|
||||||
@ -144,10 +145,12 @@ public class MessageStatusMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
throw new UnsupportedOperationException("This shouldn't be called... use writeMessage(out)");
|
throw new UnsupportedOperationException("This shouldn't be called... use writeMessage(out)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl {
|
|||||||
_messageId = id;
|
_messageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = DataHelper.readLong(in, 2);
|
_sessionId = DataHelper.readLong(in, 2);
|
||||||
@ -59,6 +60,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
throw new UnsupportedOperationException("This shouldn't be called... use writeMessage(out)");
|
throw new UnsupportedOperationException("This shouldn't be called... use writeMessage(out)");
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl {
|
|||||||
_messageId = id;
|
_messageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = DataHelper.readLong(in, 2);
|
_sessionId = DataHelper.readLong(in, 2);
|
||||||
@ -58,6 +59,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if ((_sessionId < 0) || (_messageId < 0))
|
if ((_sessionId < 0) || (_messageId < 0))
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
@ -67,6 +69,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl {
|
|||||||
_messageId = id;
|
_messageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = new SessionId();
|
_sessionId = new SessionId();
|
||||||
@ -85,6 +86,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if ((_sessionId == null) || (_severity == null) || (_reason == null))
|
if ((_sessionId == null) || (_severity == null) || (_reason == null))
|
||||||
throw new I2CPMessageException("Not enough information to construct the message");
|
throw new I2CPMessageException("Not enough information to construct the message");
|
||||||
@ -104,6 +106,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
_end = end;
|
_end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = new SessionId();
|
_sessionId = new SessionId();
|
||||||
@ -100,6 +101,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if ((_sessionId == null) || (_endpoints == null))
|
if ((_sessionId == null) || (_endpoints == null))
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
@ -120,6 +122,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
|||||||
_nonce = nonce;
|
_nonce = nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
if (true) throw new IllegalStateException("wtf, do not run me");
|
if (true) throw new IllegalStateException("wtf, do not run me");
|
||||||
}
|
}
|
||||||
@ -101,6 +102,7 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
throw new RuntimeException("wtf, dont run me");
|
throw new RuntimeException("wtf, dont run me");
|
||||||
}
|
}
|
||||||
@ -129,6 +131,7 @@ public class SendMessageMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,7 @@ public class SessionConfig extends DataStructureImpl {
|
|||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void readBytes(InputStream rawConfig) throws DataFormatException, IOException {
|
public void readBytes(InputStream rawConfig) throws DataFormatException, IOException {
|
||||||
_destination = new Destination();
|
_destination = new Destination();
|
||||||
_destination.readBytes(rawConfig);
|
_destination.readBytes(rawConfig);
|
||||||
@ -194,6 +195,7 @@ public class SessionConfig extends DataStructureImpl {
|
|||||||
_signature.readBytes(rawConfig);
|
_signature.readBytes(rawConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
if ((_destination == null) || (_options == null) || (_signature == null) || (_creationDate == null))
|
if ((_destination == null) || (_options == null) || (_signature == null) || (_creationDate == null))
|
||||||
throw new DataFormatException("Not enough data to create the session config");
|
throw new DataFormatException("Not enough data to create the session config");
|
||||||
|
@ -40,10 +40,12 @@ public class SessionId extends DataStructureImpl {
|
|||||||
_sessionId = id;
|
_sessionId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
public void readBytes(InputStream in) throws DataFormatException, IOException {
|
||||||
_sessionId = (int) DataHelper.readLong(in, 2);
|
_sessionId = (int) DataHelper.readLong(in, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
if (_sessionId < 0) throw new DataFormatException("Invalid session ID: " + _sessionId);
|
if (_sessionId < 0) throw new DataFormatException("Invalid session ID: " + _sessionId);
|
||||||
DataHelper.writeLong(out, 2, _sessionId);
|
DataHelper.writeLong(out, 2, _sessionId);
|
||||||
|
@ -55,6 +55,7 @@ public class SessionStatusMessage extends I2CPMessageImpl {
|
|||||||
_status = status;
|
_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_sessionId = new SessionId();
|
_sessionId = new SessionId();
|
||||||
@ -65,6 +66,7 @@ public class SessionStatusMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if (_sessionId == null)
|
if (_sessionId == null)
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
@ -78,6 +80,7 @@ public class SessionStatusMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ public class SetDateMessage extends I2CPMessageImpl {
|
|||||||
_date = date;
|
_date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
|
||||||
try {
|
try {
|
||||||
_date = DataHelper.readDate(in);
|
_date = DataHelper.readDate(in);
|
||||||
@ -49,6 +50,7 @@ public class SetDateMessage extends I2CPMessageImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
|
||||||
if (_date == null)
|
if (_date == null)
|
||||||
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
throw new I2CPMessageException("Unable to write out the message as there is not enough data");
|
||||||
@ -61,6 +63,7 @@ public class SetDateMessage extends I2CPMessageImpl {
|
|||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return MESSAGE_TYPE;
|
return MESSAGE_TYPE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user