changeset 1168:5119482979a5

cleanup
author Devel 1
date Tue, 16 Jun 2020 13:44:06 +0200
parents b1c2cc159e9c
children af04f9f94d35
files stress-tester/src/main/java/com/passus/st/reader/DataBlockReader.java stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgListener.java stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader.java stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader2.java stress-tester/src/main/java/com/passus/st/source/PcapSessionAnalyzerHookContext.java
diffstat 5 files changed, 3 insertions(+), 116 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/DataBlockReader.java	Tue Jun 16 12:24:52 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/DataBlockReader.java	Tue Jun 16 13:44:06 2020 +0200
@@ -6,6 +6,7 @@
 /**
  *
  * @author Mirosław Hawrot
+ * @param <T>
  */
 public interface DataBlockReader<T> extends Closeable {
 
--- a/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgListener.java	Tue Jun 16 12:24:52 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgListener.java	Tue Jun 16 13:44:06 2020 +0200
@@ -10,9 +10,5 @@
 
     void blockRead(Block block);
 
-    public static final PcapNgListener NULL_LISTENER = new PcapNgListener() {
-        @Override
-        public void blockRead(Block block) {
-        }
-    };
+    public static final PcapNgListener NULL_LISTENER = (block) -> {};
 }
--- a/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader.java	Tue Jun 16 12:24:52 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader.java	Tue Jun 16 13:44:06 2020 +0200
@@ -77,8 +77,6 @@
     }
 
     public Block readNg() throws IOException {
-        Block result = null;
-
         FileInputStreamUtils.read(fis, headerBuffer);
         position += headerBuffer.length;
 
@@ -131,6 +129,7 @@
     public void close() throws IOException {
     }
 
+    @Deprecated
     public void read(String path, PcapNgListener pcapListener, ProgressListener progress) throws IOException {
 
         try (FileInputStream fis = new FileInputStream(path);
--- a/stress-tester/src/main/java/com/passus/st/reader/pcapng/PcapNgReader2.java	Tue Jun 16 12:24:52 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-package com.passus.st.reader.pcapng;
-
-import com.passus.st.reader.pcapng.block.Block;
-import com.passus.st.reader.pcapng.block.BlockFactory;
-import com.passus.st.reader.pcapng.block.SectionHeaderBlock;
-import com.passus.st.utils.FileInputStreamUtils;
-import com.passus.data.DataHelper;
-import java.io.Closeable;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteOrder;
-
-/**
- *
- * @author mikolaj.podbielski
- */
-public class PcapNgReader2 implements Closeable {
-
-    private final FileInputStream fis;
-    private final BlockFactory factory = new BlockFactory();
-    private final byte[] discardBuffer = new byte[4];
-    private final byte[] headerBuffer = new byte[8];
-
-    private ByteOrder byteOrder = ByteOrder.nativeOrder();
-    private DataHelper mbu = DataHelper.get(byteOrder);
-
-    private final long fileSize;
-    private long position;
-    private boolean shbProcessed = false;
-
-    public PcapNgReader2(String path) throws IOException {
-        fis = new FileInputStream(path);
-        fileSize = fis.getChannel().size();
-
-    }
-
-    public Block read() throws IOException {
-        if (position < fileSize) {
-            FileInputStreamUtils.read(fis, headerBuffer);
-            position += headerBuffer.length;
-
-            int type = mbu.getInt4(headerBuffer, 0);
-            int length = mbu.getInt4(headerBuffer, 4);
-            int recordDataLength;
-
-            if (SectionHeaderBlock.isSHBHeader(headerBuffer)) {
-                shbProcessed = true;
-
-                byte byteOrderMagic[] = new byte[4];
-                FileInputStreamUtils.read(fis, byteOrderMagic);
-                position += 4;
-
-                ByteOrder newByteOrder = SectionHeaderBlock.isLittleEndian(byteOrderMagic)
-                        ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
-                if (byteOrder != newByteOrder) {
-                    byteOrder = newByteOrder;
-                    mbu = DataHelper.get(newByteOrder);
-                    length = Integer.reverseBytes(length);
-                }
-                recordDataLength = length - 16;
-            } else {
-                recordDataLength = length - 12;
-            }
-
-            if (!shbProcessed) {
-                throw new IllegalArgumentException();
-            }
-
-            if (recordDataLength > 4 * 1024 * 1024) {
-                throw new IllegalArgumentException("Pcap record is too big: " + recordDataLength);
-            }
-            byte[] recordData = new byte[recordDataLength];
-            FileInputStreamUtils.read(fis, recordData);
-            position += recordData.length;
-
-            FileInputStreamUtils.read(fis, discardBuffer);
-            position += discardBuffer.length;
-            Block block = factory.createBlock(type, recordData, byteOrder);
-
-            long padded = DataHelper.pad4(position);
-            if (padded > position) {
-                FileInputStreamUtils.skip(fis, padded - position);
-                position = padded;
-            }
-
-            return block;
-        }
-        return null;
-    }
-
-    @Override
-    public void close() throws IOException {
-        fis.close();
-    }
-
-    public ByteOrder getSectionByteOrder() {
-        return shbProcessed ? byteOrder : null;
-    }
-
-    public long getFileSize() {
-        return fileSize;
-    }
-
-    public long getPosition() {
-        return position;
-    }
-
-}
--- a/stress-tester/src/main/java/com/passus/st/source/PcapSessionAnalyzerHookContext.java	Tue Jun 16 12:24:52 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/source/PcapSessionAnalyzerHookContext.java	Tue Jun 16 13:44:06 2020 +0200
@@ -1,6 +1,5 @@
 package com.passus.st.source;
 
-import com.passus.net.http.session.HttpSessionAnalyzer;
 import com.passus.net.session.TcpSessionProcessor;
 import com.passus.net.session.UdpSessionProcessor;
 import com.passus.st.client.EventHandler;