Добавлен UnfinishedStream
This commit is contained in:
@@ -14,13 +14,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.serega6531.packmate.model.CtfService;
|
||||
import ru.serega6531.packmate.model.UnfinishedStream;
|
||||
import ru.serega6531.packmate.service.PacketService;
|
||||
import ru.serega6531.packmate.service.PatternService;
|
||||
import ru.serega6531.packmate.service.ServicesService;
|
||||
import ru.serega6531.packmate.service.StreamService;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@@ -40,6 +43,8 @@ public class PcapWorker {
|
||||
|
||||
private final String localIp;
|
||||
|
||||
private final Set<UnfinishedStream> unfinishedStreams = new HashSet<>();
|
||||
|
||||
@Autowired
|
||||
public PcapWorker(ServicesService servicesService,
|
||||
StreamService streamService,
|
||||
|
||||
5
src/main/java/ru/serega6531/packmate/Protocol.java
Normal file
5
src/main/java/ru/serega6531/packmate/Protocol.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package ru.serega6531.packmate;
|
||||
|
||||
public enum Protocol {
|
||||
TCP, UDP
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package ru.serega6531.packmate.model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import ru.serega6531.packmate.Protocol;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
@@ -27,6 +28,8 @@ public class Stream {
|
||||
@JoinColumn(name = "service_id", nullable = false)
|
||||
private CtfService service;
|
||||
|
||||
private Protocol protocol;
|
||||
|
||||
@OneToMany(mappedBy = "stream", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Packet> packets;
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package ru.serega6531.packmate.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import ru.serega6531.packmate.Protocol;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class UnfinishedStream {
|
||||
|
||||
private Inet4Address firstIp;
|
||||
private Inet4Address secondIp;
|
||||
private int firstPort;
|
||||
private int secondPort;
|
||||
private Protocol protocol;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof UnfinishedStream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UnfinishedStream o = (UnfinishedStream) obj;
|
||||
|
||||
boolean ipEq1 = firstIp.equals(o.firstIp) && secondIp.equals(o.secondIp);
|
||||
boolean ipEq2 = firstIp.equals(o.secondIp) && secondIp.equals(o.firstIp);
|
||||
boolean portEq1 = firstPort == o.firstPort && secondPort == o.secondPort;
|
||||
boolean portEq2 = firstPort == o.secondPort && secondPort == o.firstPort;
|
||||
|
||||
return (ipEq1 || ipEq2) && (portEq1 || portEq2) && protocol == o.protocol;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user