Добавлен режим работы VIEW
This commit is contained in:
@@ -22,6 +22,7 @@ import ru.serega6531.packmate.WebSocketHandler;
|
||||
import ru.serega6531.packmate.model.enums.CaptureMode;
|
||||
import ru.serega6531.packmate.pcap.FilePcapWorker;
|
||||
import ru.serega6531.packmate.pcap.LivePcapWorker;
|
||||
import ru.serega6531.packmate.pcap.NoOpPcapWorker;
|
||||
import ru.serega6531.packmate.pcap.PcapWorker;
|
||||
import ru.serega6531.packmate.service.ServicesService;
|
||||
import ru.serega6531.packmate.service.StreamService;
|
||||
@@ -58,11 +59,11 @@ public class ApplicationConfiguration extends WebSecurityConfigurerAdapter imple
|
||||
@Value("${interface-name}") String interfaceName,
|
||||
@Value("${pcap-file}") String filename,
|
||||
@Value("${capture-mode}") CaptureMode captureMode) throws PcapNativeException, UnknownHostException {
|
||||
if(captureMode == CaptureMode.LIVE) {
|
||||
return new LivePcapWorker(servicesService, streamService, localIpString, interfaceName);
|
||||
} else {
|
||||
return new FilePcapWorker(servicesService, streamService, subscriptionService, localIpString, filename);
|
||||
}
|
||||
return switch (captureMode) {
|
||||
case LIVE -> new LivePcapWorker(servicesService, streamService, localIpString, interfaceName);
|
||||
case FILE -> new FilePcapWorker(servicesService, streamService, subscriptionService, localIpString, filename);
|
||||
default -> new NoOpPcapWorker();
|
||||
};
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -2,6 +2,6 @@ package ru.serega6531.packmate.model.enums;
|
||||
|
||||
public enum CaptureMode {
|
||||
|
||||
LIVE, FILE
|
||||
LIVE, FILE, VIEW
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.serega6531.packmate.service;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.pcap4j.core.PcapNativeException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -8,6 +7,7 @@ import org.springframework.stereotype.Service;
|
||||
import ru.serega6531.packmate.model.CtfService;
|
||||
import ru.serega6531.packmate.model.enums.SubscriptionMessageType;
|
||||
import ru.serega6531.packmate.model.pojo.SubscriptionMessage;
|
||||
import ru.serega6531.packmate.pcap.NoOpPcapWorker;
|
||||
import ru.serega6531.packmate.pcap.PcapWorker;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -17,7 +17,6 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class PcapService {
|
||||
|
||||
@Getter
|
||||
private boolean started = false;
|
||||
|
||||
private final SubscriptionService subscriptionService;
|
||||
@@ -29,6 +28,10 @@ public class PcapService {
|
||||
this.worker = worker;
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return started || worker instanceof NoOpPcapWorker;
|
||||
}
|
||||
|
||||
public synchronized void start() throws PcapNativeException {
|
||||
if(!started) {
|
||||
started = true;
|
||||
|
||||
Reference in New Issue
Block a user