public DataStructure createDataStructure() throws DataFormatException { AbuseReason res = new AbuseReason(); res.setReason("Because they're mean"); return res; } public DataStructure createStructureToRead() { return new AbuseReason(); }
@Override public boolean equals(Object object) { if ((object == null) || !(object instanceof AbuseReason)) return false; return DataHelper.eq(_reason, ((AbuseReason) object).getReason()); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _severity = new AbuseSeverity(); _severity.readBytes(in); _reason = new AbuseReason(); _reason.readBytes(in); _messageId = new MessageId(); _messageId.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
public DataStructure createStructureToRead() { return new AbuseReason(); } }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId == null) || (_severity == null) || (_reason == null)) throw new I2CPMessageException("Not enough information to construct the message"); ByteArrayOutputStream os = new ByteArrayOutputStream(32); try { _sessionId.writeBytes(os); _severity.writeBytes(os); _reason.writeBytes(os); if (_messageId == null) { _messageId = new MessageId(); _messageId.setMessageId(0); } _messageId.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
/** * Send an abuse message to the router */ public void reportAbuse(I2PSessionImpl session, int msgId, int severity) throws I2PSessionException { ReportAbuseMessage msg = new ReportAbuseMessage(); MessageId id = new MessageId(); id.setMessageId(msgId); msg.setMessageId(id); AbuseReason reason = new AbuseReason(); reason.setReason("Not specified"); msg.setReason(reason); AbuseSeverity sv = new AbuseSeverity(); sv.setSeverity(severity); msg.setSeverity(sv); session.sendMessage(msg); }
public void runJob() { if (_runner.isDead()) return; AbuseReason res = new AbuseReason(); res.setReason(_reason); AbuseSeverity sev = new AbuseSeverity(); sev.setSeverity(_severity); ReportAbuseMessage msg = new ReportAbuseMessage(); msg.setReason(res); SessionId id = _runner.getSessionId(_dest.calculateHash()); if (id == null) return; msg.setSessionId(id); msg.setSeverity(sev); try { _runner.doSend(msg); } catch (I2CPMessageException ime) { _log.error("Error reporting abuse", ime); } } }