Исправлен поиск в прошлом и сборка фронтенда
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user