Добавлен ttl стримов
This commit is contained in:
@@ -95,6 +95,7 @@ public class PcapWorker implements PacketListener {
|
||||
String destIpString = null;
|
||||
int sourcePort = -1;
|
||||
int destPort = -1;
|
||||
byte ttl = 0;
|
||||
byte[] content = null;
|
||||
Protocol protocol = null;
|
||||
boolean ack = false;
|
||||
@@ -107,6 +108,7 @@ public class PcapWorker implements PacketListener {
|
||||
destIp = header.getDstAddr();
|
||||
sourceIpString = header.getSrcAddr().getHostAddress();
|
||||
destIpString = header.getDstAddr().getHostAddress();
|
||||
ttl = header.getTtl();
|
||||
}
|
||||
|
||||
if (rawPacket.contains(TcpPacket.class)) {
|
||||
@@ -142,6 +144,7 @@ public class PcapWorker implements PacketListener {
|
||||
|
||||
ru.serega6531.packmate.model.Packet packet = ru.serega6531.packmate.model.Packet.builder()
|
||||
.tempId(packetIdCounter++)
|
||||
.ttl(ttl)
|
||||
.timestamp(System.currentTimeMillis())
|
||||
.incoming(incoming)
|
||||
.content(content)
|
||||
|
||||
@@ -33,6 +33,10 @@ public class Packet {
|
||||
@JsonIgnore
|
||||
private Long tempId;
|
||||
|
||||
@Transient
|
||||
@JsonIgnore
|
||||
private byte ttl;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "stream_id", nullable = false)
|
||||
@JsonIgnore
|
||||
|
||||
@@ -45,4 +45,6 @@ public class Stream {
|
||||
|
||||
private boolean favorite;
|
||||
|
||||
private byte ttl;
|
||||
|
||||
}
|
||||
|
||||
@@ -76,8 +76,13 @@ public class StreamService {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<Packet> firstIncoming = packets.stream()
|
||||
.filter(Packet::isIncoming)
|
||||
.findFirst();
|
||||
|
||||
Stream stream = new Stream();
|
||||
stream.setProtocol(unfinishedStream.getProtocol());
|
||||
stream.setTtl(firstIncoming.isPresent() ? firstIncoming.get().getTtl() : 0);
|
||||
stream.setStartTimestamp(packets.get(0).getTimestamp());
|
||||
stream.setEndTimestamp(packets.get(packets.size() - 1).getTimestamp());
|
||||
stream.setService(serviceOptional.get());
|
||||
@@ -183,6 +188,8 @@ public class StreamService {
|
||||
IOUtils.copy(gzipStream, out);
|
||||
byte[] newContent = ArrayUtils.addAll(httpHeader, out.toByteArray());
|
||||
|
||||
log.debug("Разархивирован gzip: {} -> {} байт", gzipBytes.length, out.size());
|
||||
|
||||
return Packet.builder()
|
||||
.incoming(false)
|
||||
.timestamp(packets.get(0).getTimestamp())
|
||||
|
||||
Reference in New Issue
Block a user