mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
simplify
This commit is contained in:
@@ -18,6 +18,7 @@ package net.schmizz.sshj.common;
|
||||
/** SSH message identifiers */
|
||||
public enum Message {
|
||||
|
||||
UNKNOWN(0),
|
||||
DISCONNECT(1),
|
||||
IGNORE(2),
|
||||
UNIMPLEMENTED(3),
|
||||
@@ -68,6 +69,10 @@ public enum Message {
|
||||
static {
|
||||
for (Message c : Message.values())
|
||||
cache[c.toByte()] = c;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (cache[i] == null)
|
||||
cache[i] = UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public static Message fromByte(byte b) {
|
||||
|
||||
@@ -76,11 +76,7 @@ public class SSHPacket
|
||||
* @return the message identifier
|
||||
*/
|
||||
public Message readMessageID() {
|
||||
byte b = readByte();
|
||||
Message cmd = Message.fromByte(b);
|
||||
if (cmd == null)
|
||||
throw new BufferException("Unknown message ID: " + b);
|
||||
return cmd;
|
||||
return Message.fromByte(readByte());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user