Skip to content

Commit

Permalink
Bumped version to 1.2.20; includes fixes for RTMP/E
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed Apr 11, 2022
1 parent edb5459 commit 3ec498b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.red5</groupId>
<artifactId>red5-parent</artifactId>
<version>1.2.19</version>
<version>1.2.20</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-server</artifactId>
Expand Down
44 changes: 25 additions & 19 deletions src/main/java/org/red5/server/net/rtmpe/RTMPEIoFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,35 @@ public void messageReceived(NextFilter nextFilter, IoSession session, Object obj
log.warn("Client was rejected due to invalid handshake");
conn.close();
}
} else {
// don't fall through to connected process if we didn't have enough for the handshake
break;
}
// allow fall-through
case RTMP.STATE_CONNECTED:
IoBuffer message = buffer.getBufferAsIoBuffer();
// assuming majority of connections will not be encrypted
if (!((RTMPConnection) conn).isEncrypted()) {
log.trace("Receiving message: {}", message);
nextFilter.messageReceived(session, message);
} else {
Cipher cipher = (Cipher) session.getAttribute(RTMPConnection.RTMPE_CIPHER_IN);
if (cipher != null) {
if (log.isDebugEnabled()) {
log.debug("Decrypting message: {}", message);
}
byte[] encrypted = new byte[message.remaining()];
message.get(encrypted);
message.free();
byte[] plain = cipher.update(encrypted);
IoBuffer messageDecrypted = IoBuffer.wrap(plain);
if (log.isDebugEnabled()) {
log.debug("Receiving decrypted message: {}", messageDecrypted);
// skip empty buffer
if (buffer.getBufferSize() > 0) {
IoBuffer message = buffer.getBufferAsIoBuffer();
// assuming majority of connections will not be encrypted
if (!((RTMPConnection) conn).isEncrypted()) {
log.trace("Receiving message: {}", message);
nextFilter.messageReceived(session, message);
} else {
Cipher cipher = (Cipher) session.getAttribute(RTMPConnection.RTMPE_CIPHER_IN);
if (cipher != null) {
if (log.isDebugEnabled()) {
log.debug("Decrypting message: {}", message);
}
byte[] encrypted = new byte[message.remaining()];
message.get(encrypted);
message.free();
byte[] plain = cipher.update(encrypted);
IoBuffer messageDecrypted = IoBuffer.wrap(plain);
if (log.isDebugEnabled()) {
log.debug("Receiving decrypted message: {}", messageDecrypted);
}
nextFilter.messageReceived(session, messageDecrypted);
}
nextFilter.messageReceived(session, messageDecrypted);
}
}
break;
Expand Down

0 comments on commit 3ec498b

Please sign in to comment.