Исправлен поиск в прошлом и сборка фронтенда

This commit is contained in:
sshkurov
2021-12-05 13:34:57 +03:00
parent 1219670d51
commit 7cf7233c4b
3 changed files with 8 additions and 11 deletions

View File

@@ -1,6 +1,5 @@
package ru.serega6531.packmate.service;
import com.google.common.collect.Iterables;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,9 +63,8 @@ public class PatternService {
return new PatternMatcher(bytes, list).findMatches();
}
public Optional<FoundPattern> tryMatch(byte[] bytes, Pattern pattern) {
Set<FoundPattern> matches = new PatternMatcher(bytes, List.of(pattern)).findMatches();
return Optional.ofNullable(Iterables.getOnlyElement(matches, null));
public Set<FoundPattern> matchOne(byte[] bytes, Pattern pattern) {
return new PatternMatcher(bytes, List.of(pattern)).findMatches();
}
public void enable(int id, boolean enabled) {

View File

@@ -200,12 +200,11 @@ public class StreamService {
continue;
}
final Optional<FoundPattern> matchOpt = patternService.tryMatch(packet.getContent(), pattern);
final Set<FoundPattern> matches = patternService.matchOne(packet.getContent(), pattern);
if (matchOpt.isPresent()) {
FoundPattern match = matchOpt.get();
packet.getMatches().add(match);
match.setPacket(packet);
if (!matches.isEmpty()) {
packet.getMatches().addAll(matches);
matches.forEach(m -> m.setPacket(packet));
matched = true;
}