Рефакторинг
This commit is contained in:
10
README_EN.md
10
README_EN.md
@@ -86,7 +86,7 @@ If everything went fine, Packmate will be available on port `65000` from any hos
|
||||
When you open a web interface for the first time, you will be asked for a login and password
|
||||
you specified in the env file.
|
||||
After entering the credentials, open the settings by clicking on the cogs
|
||||
in the top right corner and enter login and password again.
|
||||
in the top right corner and enter the specified login and password again.
|
||||
|
||||

|
||||
|
||||
@@ -109,10 +109,10 @@ you can click a button in the sidebar to switch between binary and text views.
|
||||
|
||||
### Shortcuts
|
||||
To quickly navigate streams you can use the following shortcuts:
|
||||
* `Ctrl+Up` -- go to next stream
|
||||
* `Ctrl+Down` -- go to previous stream
|
||||
* `Ctrl+Home` -- go to latest stream
|
||||
* `Ctrl+End` -- go to first stream
|
||||
* `Ctrl+Up` -- go to the next stream
|
||||
* `Ctrl+Down` -- go to the previous stream
|
||||
* `Ctrl+Home` -- go to the latest stream
|
||||
* `Ctrl+End` -- go to the first stream
|
||||
|
||||
<div align="right">
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
import ru.serega6531.packmate.service.SubscriptionService;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Component
|
||||
public class WebSocketHandler extends TextWebSocketHandler {
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import java.util.Map;
|
||||
@Getter
|
||||
public class CountersHolder {
|
||||
|
||||
private Map<Integer, Integer> servicesPackets;
|
||||
private Map<Integer, Integer> servicesStreams;
|
||||
private final Map<Integer, Integer> servicesPackets;
|
||||
private final Map<Integer, Integer> servicesStreams;
|
||||
|
||||
private int totalPackets;
|
||||
private int totalStreams;
|
||||
private final int totalPackets;
|
||||
private final int totalStreams;
|
||||
|
||||
public CountersHolder(Map<Integer, Integer> servicesPackets, Map<Integer, Integer> servicesStreams,
|
||||
int totalPackets, int totalStreams) {
|
||||
|
||||
@@ -10,11 +10,11 @@ import java.net.Inet4Address;
|
||||
@Getter
|
||||
public class UnfinishedStream {
|
||||
|
||||
private Inet4Address firstIp;
|
||||
private Inet4Address secondIp;
|
||||
private int firstPort;
|
||||
private int secondPort;
|
||||
private Protocol protocol;
|
||||
private final Inet4Address firstIp;
|
||||
private final Inet4Address secondIp;
|
||||
private final int firstPort;
|
||||
private final int secondPort;
|
||||
private final Protocol protocol;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
@@ -58,7 +58,8 @@ public class FilePcapWorker extends AbstractPcapWorker {
|
||||
gotPacket(packet);
|
||||
} catch (PcapNativeException e) {
|
||||
log.error("Pcap read error: {}", e.getMessage());
|
||||
Thread.sleep(100);
|
||||
//noinspection BusyWait
|
||||
Thread.sleep(100); // чтобы ошибки не летели слишком быстро
|
||||
} catch (EOFException e) {
|
||||
stop();
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ public class CountingService {
|
||||
|
||||
private final SubscriptionService subscriptionService;
|
||||
|
||||
private Map<Integer, Counter> servicesPackets = new HashMap<>();
|
||||
private Map<Integer, Counter> servicesStreams = new HashMap<>();
|
||||
private final Map<Integer, Counter> servicesPackets = new HashMap<>();
|
||||
private final Map<Integer, Counter> servicesStreams = new HashMap<>();
|
||||
|
||||
private Counter totalPackets = new Counter();
|
||||
private Counter totalStreams = new Counter();
|
||||
|
||||
@@ -32,15 +32,9 @@ class PatternMatcher {
|
||||
|
||||
private void match(Pattern pattern) {
|
||||
switch (pattern.getSearchType()) {
|
||||
case REGEX:
|
||||
matchRegex(pattern);
|
||||
break;
|
||||
case SUBSTRING:
|
||||
matchSubstring(pattern);
|
||||
break;
|
||||
case SUBBYTES:
|
||||
matchSubbytes(pattern);
|
||||
break;
|
||||
case REGEX -> matchRegex(pattern);
|
||||
case SUBSTRING -> matchSubstring(pattern);
|
||||
case SUBBYTES -> matchSubbytes(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class HttpChunksProcessor {
|
||||
|
||||
private List<Packet> packets;
|
||||
private final List<Packet> packets;
|
||||
|
||||
public void processChunkedEncoding() {
|
||||
boolean chunkStarted = false;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class HttpGzipProcessor {
|
||||
|
||||
private static final byte[] GZIP_HEADER = {0x1f, (byte) 0x8b, 0x08};
|
||||
|
||||
private List<Packet> packets;
|
||||
private final List<Packet> packets;
|
||||
|
||||
/**
|
||||
* Попытаться распаковать GZIP из исходящих http пакетов. <br>
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class HttpUrldecodeProcessor {
|
||||
|
||||
private List<Packet> packets;
|
||||
private final List<Packet> packets;
|
||||
|
||||
/**
|
||||
* Декодирование urlencode с http пакета до смены стороны или окончания стрима
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class PacketsMerger {
|
||||
|
||||
private List<Packet> packets;
|
||||
private final List<Packet> packets;
|
||||
|
||||
/**
|
||||
* Сжать соседние пакеты в одном направлении в один.
|
||||
|
||||
@@ -5,11 +5,11 @@ import lombok.experimental.UtilityClass;
|
||||
@UtilityClass
|
||||
public class Bytes {
|
||||
|
||||
public static int indexOf(byte[] array, byte[] target) {
|
||||
public int indexOf(byte[] array, byte[] target) {
|
||||
return indexOf(array, target, 0, array.length);
|
||||
}
|
||||
|
||||
public static int indexOf(byte[] array, byte[] target, int start, int end) {
|
||||
public int indexOf(byte[] array, byte[] target, int start, int end) {
|
||||
if (target.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Optional;
|
||||
@UtilityClass
|
||||
public class PacketUtils {
|
||||
|
||||
public static Optional<byte[]> mergePackets(List<Packet> cut) {
|
||||
public Optional<byte[]> mergePackets(List<Packet> cut) {
|
||||
return cut.stream()
|
||||
.map(Packet::getContent)
|
||||
.reduce(ArrayUtils::addAll);
|
||||
|
||||
Reference in New Issue
Block a user