Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for more required fields #159

Merged
merged 7 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static boolean requireField(Field<?> field, Envelope envelope) {
}
}

public static boolean requireNodeRecord(Envelope envelope) {
public static boolean requireSessionWithNodeRecord(Envelope envelope) {
if (!requireField(Field.SESSION, envelope)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void handle(Envelope envelope) {
LOG.trace(
() ->
String.format(
"Envelope %s in BadPacketLogger, requirements are satisfied!",
"Envelope %s in BadPacketHandler, requirements are satisfied!",
envelope.getIdString()));

LOG.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void handle(Envelope envelope) {
LOG.trace(
() ->
String.format(
"Envelope %s in AuthHeaderMessagePacketHandler, requirements are satisfied!",
"Envelope %s in HandshakeMessagePacketHandler, requirements are satisfied!",
envelope.getIdString()));

HandshakeMessagePacket packet = envelope.get(Field.PACKET_HANDSHAKE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void handle(Envelope envelope) {
if (!HandlerUtil.requireField(Field.MESSAGE, envelope)) {
return;
}
if (!HandlerUtil.requireNodeRecord(envelope)) {
if (!HandlerUtil.requireSessionWithNodeRecord(envelope)) {
return;
}
LOG.trace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void tryToSendAwaitTaskIfAny(

@Override
public void handle(Envelope envelope) {
if (!HandlerUtil.requireNodeRecord(envelope)) {
if (!HandlerUtil.requireSessionWithNodeRecord(envelope)) {
return;
}
LOG.trace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void handle(final Envelope envelope) {
return;
}
LOG.trace(
"Envelope {} in NodeIdToSession, requirements are satisfied!", envelope.getIdString());
"Envelope {} in NodeSessionManager, requirements are satisfied!", envelope.getIdString());

SessionLookup sessionRequest = envelope.get(Field.SESSION_LOOKUP);
envelope.remove(Field.SESSION_LOOKUP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void handle(Envelope envelope) {
LOG.trace(
() ->
String.format(
"Envelope %s in UnknownPacketTypeByStatus, requirements are satisfied!",
"Envelope %s in PacketDispatcherHandler, requirements are satisfied!",
envelope.getIdString()));

Packet<?> packet = envelope.get(Field.PACKET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void handle(Envelope envelope) {
LOG.trace(
() ->
String.format(
"Envelope %s in NotExpectedIncomingPacketHandler, requirements are satisfied!",
"Envelope %s in UnauthorizedMessagePacketHandler, requirements are satisfied!",
envelope.getIdString()));

NodeSession session = envelope.get(Field.SESSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ public WhoAreYouPacketHandler(final Pipeline outgoingPipeline, final Scheduler s

@Override
public void handle(final Envelope envelope) {
if (!HandlerUtil.requireNodeRecord(envelope)) {
if (!HandlerUtil.requireSessionWithNodeRecord(envelope)) {
return;
}
if (!HandlerUtil.requireField(Field.PACKET_WHOAREYOU, envelope)) {
return;
}
if (!HandlerUtil.requireField(Field.MASKING_IV, envelope)) {
throw new IllegalStateException("Internal error: No MASKING_IV field for WhoAreYou packet");
}
LOG.trace(
() ->
String.format(
Expand Down Expand Up @@ -82,9 +85,6 @@ public void handle(final Envelope envelope) {

// The handshake uses the unmasked WHOAREYOU challenge as an input:
// challenge-data = masking-iv || static-header || authdata
if (!envelope.contains(Field.MASKING_IV)) {
throw new IllegalStateException("Internal error: No MASKING_IV field for WhoAreYou packet");
}
Bytes16 whoAreYouMaskingIV = envelope.get(Field.MASKING_IV);
Bytes challengeData =
Bytes.wrap(
Expand Down