Исправлен хэш UA

This commit is contained in:
serega6531
2019-11-27 00:30:17 +03:00
parent 98a5eddd0a
commit 1d32f49a1d
4 changed files with 6 additions and 9 deletions

View File

@@ -2,12 +2,6 @@ package ru.serega6531.packmate.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import ru.serega6531.packmate.model.Pattern; import ru.serega6531.packmate.model.Pattern;
import ru.serega6531.packmate.model.enums.PatternDirectionType;
import java.util.List;
public interface PatternRepository extends JpaRepository<Pattern, Integer> { public interface PatternRepository extends JpaRepository<Pattern, Integer> {
List<Pattern> findAllByTypeEqualsOrTypeEquals(PatternDirectionType type, PatternDirectionType both);
} }

View File

@@ -68,13 +68,15 @@ public class PatternService {
String content = new String(bytes); String content = new String(bytes);
final java.util.regex.Pattern regex = compilePattern(pattern); final java.util.regex.Pattern regex = compilePattern(pattern);
final Matcher matcher = regex.matcher(content); final Matcher matcher = regex.matcher(content);
int startPos = 0;
while (matcher.find()) { while (matcher.find(startPos)) {
found.add(FoundPattern.builder() found.add(FoundPattern.builder()
.patternId(pattern.getId()) .patternId(pattern.getId())
.startPosition(matcher.start()) .startPosition(matcher.start())
.endPosition(matcher.end()) .endPosition(matcher.end())
.build()); .build());
startPos = matcher.end() + 1;
} }
return found; return found;

View File

@@ -43,7 +43,7 @@ public class StreamService {
private final boolean ignoreEmptyPackets; private final boolean ignoreEmptyPackets;
private final byte[] GZIP_HEADER = {0x1f, (byte) 0x8b, 0x08}; private final byte[] GZIP_HEADER = {0x1f, (byte) 0x8b, 0x08};
private final java.util.regex.Pattern userAgentPattern = java.util.regex.Pattern.compile("User-Agent: (.+)\\n"); private final java.util.regex.Pattern userAgentPattern = java.util.regex.Pattern.compile("User-Agent: (.+)\\r\\n");
@Autowired @Autowired
public StreamService(StreamRepository repository, public StreamService(StreamRepository repository,

View File

@@ -21,3 +21,4 @@ account-password: 123456
udp-stream-timeout: 20 # секунд udp-stream-timeout: 20 # секунд
tcp-stream-timeout: 40 # секунд tcp-stream-timeout: 40 # секунд
timeout-stream-check-interval: 10 # секунд timeout-stream-check-interval: 10 # секунд
ignore-empty-packets: true