Работа над фильтрацией через libpcap

This commit is contained in:
serega6531
2020-04-13 00:56:52 +03:00
parent 9720619eb8
commit b5a276d961
2 changed files with 8 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ public abstract class AbstractPcapWorker implements PcapWorker, PacketListener {
protected PcapHandle pcap = null; protected PcapHandle pcap = null;
protected final ExecutorService loopExecutorService; protected final ExecutorService loopExecutorService;
protected String filter = null; protected String filter = "tcp or udp";
// во время работы должен быть != null // во время работы должен быть != null
protected ExecutorService processorExecutorService; protected ExecutorService processorExecutorService;

View File

@@ -3,6 +3,7 @@ package ru.serega6531.packmate.service;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.serega6531.packmate.model.CtfService; import ru.serega6531.packmate.model.CtfService;
import ru.serega6531.packmate.model.enums.SubscriptionMessageType; import ru.serega6531.packmate.model.enums.SubscriptionMessageType;
@@ -32,7 +33,7 @@ public class ServicesService {
@Autowired @Autowired
public ServicesService(ServiceRepository repository, public ServicesService(ServiceRepository repository,
SubscriptionService subscriptionService, SubscriptionService subscriptionService,
PcapService pcapService, @Lazy PcapService pcapService,
@Value("${local-ip}") String localIpString) throws UnknownHostException { @Value("${local-ip}") String localIpString) throws UnknownHostException {
this.repository = repository; this.repository = repository;
this.subscriptionService = subscriptionService; this.subscriptionService = subscriptionService;
@@ -63,9 +64,13 @@ public class ServicesService {
public void deleteByPort(int port) { public void deleteByPort(int port) {
log.info("Removed service at port {}", port); log.info("Removed service at port {}", port);
services.remove(port); services.remove(port);
repository.deleteById(port); repository.deleteById(port);
subscriptionService.broadcast(new SubscriptionMessage(SubscriptionMessageType.DELETE_SERVICE, port)); subscriptionService.broadcast(new SubscriptionMessage(SubscriptionMessageType.DELETE_SERVICE, port));
pcapService.updateFilter(findAll());
} }
public CtfService save(CtfService service) { public CtfService save(CtfService service) {
@@ -73,6 +78,7 @@ public class ServicesService {
final CtfService saved = repository.save(service); final CtfService saved = repository.save(service);
services.put(saved.getPort(), saved); services.put(saved.getPort(), saved);
subscriptionService.broadcast(new SubscriptionMessage(SubscriptionMessageType.SAVE_SERVICE, saved)); subscriptionService.broadcast(new SubscriptionMessage(SubscriptionMessageType.SAVE_SERVICE, saved));
pcapService.updateFilter(findAll()); pcapService.updateFilter(findAll());