Skip to content

Commit 279ffa7

Browse files
committed
* Revert to not sending errors for set ip cmd broadcast
Signed-off-by: Piotr Sobiech <[email protected]>
1 parent 9056c78 commit 279ffa7

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

modules/vclu/src/main/java/pl/psobiech/opengr8on/vclu/Server.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,22 @@ private Optional<Response> onSetIpCommand(boolean broadcast, UUID uuid, Request
373373
logCommand(uuid, request, command);
374374

375375
if (Objects.equals(cluDevice.getSerialNumber(), command.getSerialNumber())) {
376-
// we cant change IP address, so we only accept current ip address
377-
return Optional.of(
378-
new Response(
379-
request.cipherKey(),
380-
SetIpCommand.response(
381-
cluDevice.getSerialNumber(),
382-
cluDevice.getAddress()
376+
if (command.getIpAddress().equals(cluDevice.getAddress())) {
377+
// we cant change IP address, so we only accept current ip address
378+
return Optional.of(
379+
new Response(
380+
request.cipherKey(),
381+
SetIpCommand.response(
382+
cluDevice.getSerialNumber(),
383+
cluDevice.getAddress()
384+
)
383385
)
384-
)
385-
);
386+
);
387+
}
386388
}
387389

388390
if (broadcast) {
391+
// if message was a broadcast, we should not spam errors
389392
return Optional.empty();
390393
}
391394

modules/vclu/src/test/java/pl/psobiech/opengr8on/vclu/ServerCommandTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ void setAddressUnsupported() throws Exception {
130130
try (CLUClient client = new CLUClient(LOCALHOST, server.getServer().getDevice(), projectCipherKey, LOCALHOST, server.getPort())) {
131131
final Optional<Inet4Address> addressOptional = client.setAddress(IPv4AddressUtil.parseIPv4("1.1.1.1"), LOCALHOST);
132132

133-
assertTrue(addressOptional.isPresent());
134-
assertEquals(LOCALHOST, addressOptional.get());
133+
assertFalse(addressOptional.isPresent());
135134
}
136135
}
137136
}

0 commit comments

Comments
 (0)